1.Please, can someone tell me how to create a row of text boxes that are scrollable to left or right in flutter inside a ListView. I can see that I am trying to define an in
I have managed to do this by using ListView.builder()
Here is the full code:
import 'package:flutter/material.dart';
void main() {
runApp(new MaterialApp(
home: new MyApp()));
}
class MyApp extends StatefulWidget {
@override
State createState() {
return new _MyAppState();
}
}
class _MyAppState extends State {
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text("Scroll on the Horizon"),
centerTitle: true,
),
body: new ListView.builder(
scrollDirection: Axis.horizontal,
itemBuilder: (BuildContext context, int index) {
return new Row(
children: [
new Text("Let ", style: new TextStyle(color: Colors.blue),),
new Text("me ", style: new TextStyle(color: Colors.red)),
new Text("scroll ", style: new TextStyle(color: Colors.green)),
new Text("horizontally ",
style: new TextStyle(color: Colors.orange)),
new Text("Let ", style: new TextStyle(color: Colors.blue),),
new Text("me ", style: new TextStyle(color: Colors.red)),
new Text("scroll ", style: new TextStyle(color: Colors.green)),
new Text("horizontally ",
style: new TextStyle(color: Colors.orange)),
new Text("Let ", style: new TextStyle(color: Colors.blue),),
new Text("me ", style: new TextStyle(color: Colors.red)),
new Text("scroll ", style: new TextStyle(color: Colors.green)),
new Text("horizontally ",
style: new TextStyle(color: Colors.orange)),
new Text("Let ", style: new TextStyle(color: Colors.blue),),
new Text("me ", style: new TextStyle(color: Colors.red)),
new Text("scroll ", style: new TextStyle(color: Colors.green)),
new Text("horizontally ",
style: new TextStyle(color: Colors.orange)),
],
);
},
));
}
}
Do not forget to set scrollDirection
property to Axis.horizontal
, since it is defaulted to the vertical
value.