I am trying to make ListView.builder
horizontal scrolling from right to left
My code:
SliverToBoxAdapter(
child: Container(
height: MediaQuery.of(context).size.height / 4.5,
margin: const EdgeInsets.only(bottom: 5.0, top: 10.0),
child: ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: list.length,
itemBuilder: (BuildContext context, int index) {
return InkWell(/* ... */)
}
),
),
);
You might want to create a list that scrolls horizontally rather than vertically. The ListView widget supports horizontal lists. Use the standard ListView constructor, passing in a horizontal scrollDirection , which overrides the default vertical direction.
To scroll a Flutter ListView widget horizontally, set scrollDirection property of the ListView widget to Axis. horizontal. This arranges the items side by side horzontally. Following is the basic syntax to arrange the items horizontally in a ListView and scroll them horizontally.
Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main. xml. Step 5 − Add the following code to res/layout/movies_list.
You just need to add reverse parameter to the ListView
here is an example:
ListView.builder(
reverse: true,
scrollDirection: Axis.horizontal,
itemCount: list.length,
itemBuilder: (context, position) {
return Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
child: Text(list[position]),
color: Colors.grey,
height: 10,
width: 10,
),
);
},
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With