Want to create a row of scrollable text boxes or widgets in flutter inside a ListView? This is straightforward as long as you put a container of fixed height on your horizontal ListView.
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 | import 'package:flutter/material.dart'; import 'package:flutter/gestures.dart'; import 'dart:collection'; void main() { runApp(new MaterialApp(home: new DemoApp())); } class DemoApp extends StatelessWidget { @override Widget build(BuildContext context) { return new Scaffold( appBar: new AppBar(title: new Text('Nested ListView Example')), body: new Center( child: new ListView( children: <Widget>[ new Container( height: 80.0, child: new ListView( scrollDirection: Axis.horizontal, children: new List.generate(10, (int index) { return new Card( color: Colors.blue[index * 100], child: new Container( width: 50.0, height: 50.0, child: new Text("$index"), ), ); }), ), ), ], ), ), ); } } |
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.