List of horizontal list in Flutter. I guess what you want is a list within a another list Here is the adaptation of the sample program that you have followed The build method is like:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | Widget build(BuildContext context) { Widget horizontalList1 = new Container( margin: EdgeInsets.symmetric(vertical: 20.0), height: 200.0, child: new ListView( scrollDirection: Axis.horizontal, children: <Widget>[ Container(width: 160.0, color: Colors.red,), Container(width: 160.0, color: Colors.orange,), Container(width: 160.0, color: Colors.pink,), Container(width: 160.0, color: Colors.yellow,), ], ) ); Widget horizontalList2 = new Container( margin: EdgeInsets.symmetric(vertical: 20.0), height: 200.0, child: new ListView( scrollDirection: Axis.horizontal, children: <Widget>[ Container(width: 160.0, color: Colors.blue,), Container(width: 160.0, color: Colors.green,), Container(width: 160.0, color: Colors.cyan,), Container(width: 160.0, color: Colors.black,), ], ) ); return new Scaffold( appBar: new AppBar( title: new Text(widget.title), ), body: new Center( child: new Container( child: ListView( scrollDirection: Axis.vertical, children: <Widget>[ horizontalList1, horizontalList2, ], ), ), ), // This trailing comma makes auto-formatting nicer for build methods. ); |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.