Implementing a bidirectional listview in Flutter. Here’s a potential solution using an outer SingleChildScrollView. You could also use a PageView of multiple ListViews if you’re ok with the offscreen ListViews being torn down.
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 | import 'package:flutter/material.dart'; void main() { runApp(new MaterialApp( home: new MyHomePage(), )); } class MyHomePage extends StatelessWidget { Widget build(BuildContext context) { ThemeData themeData = Theme.of(context); return new Scaffold( body: new SingleChildScrollView( scrollDirection: Axis.horizontal, child: new SizedBox( width: 1000.0, child: new ListView.builder( itemBuilder: (BuildContext context, int i) { return new Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: new List.generate(5, (int j) { return new Text("$i,$j", style: themeData.textTheme.display2); }), ); }, ), ), ), ); } } |
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.