Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add RTL to ListView.builder horizontal flutter

Tags:

flutter

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(/* ... */)
      }
    ),
  ),
);
like image 904
Mikel Tawfik Avatar asked Sep 08 '19 02:09

Mikel Tawfik


People also ask

How do I make ListView builder horizontal in flutter?

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.

How do I add a horizontal scrollbar to my flutter?

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.

How do you make a ListView horizontal?

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.


1 Answers

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,
        ),
      );
    },
  )
like image 180
Basel Abuhadrous Avatar answered Oct 20 '22 07:10

Basel Abuhadrous