26

What is the alternative to Recycle view in flutter I have tried using this code but how to do Animination with listview widget in flutter

Is this valid?

 ListView(
 children: <Widget>[
ListTile(
  leading: Icon(Icons.map),
  title: Text('Map'),
),
ListTile(
  leading: Icon(Icons.photo_album),
  title: Text('Album'),
),
ListTile(
  leading: Icon(Icons.phone),
  title: Text('Phone'),
  ),
 ],
);
MRizwan33
  • 2,723
  • 6
  • 31
  • 42
  • 3
    RecyclerView is essentially an enhanced version of a ListView. I'd assume ListView in flutter isn't the same as a RecyclerView, but a regular ListView – Zoe Jun 20 '18 at 10:09

3 Answers3

24

ListView:

Usually this should be used with a small number of children as the List will also construct the invisible elements in the list and a large amount of elements may render this inefficient.

ListView.builder():

The list items are constructed lazily, meaning only a specific number of list items are constructed and when a user scrolls ahead, the earlier ones are destroyed.

More info is here.

Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135
CaballeroF
  • 341
  • 2
  • 4
7

Following flutter-for/android-devs

The recommended, efficient, and effective way to build a list uses a ListView.Builder. This method is great when you have a dynamic List or a List with very large amounts of data. This is essentially the equivalent of RecyclerView on Android, which automatically recycles list elements for you:

@override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text("Sample App"),
        ),
        body: ListView.builder(
            itemCount: widgets.length,
            itemBuilder: (BuildContext context, int position) {
              return getRow(position);
            }));
  }

  Widget getRow(int i) {
    return GestureDetector(
      child: Padding(
          padding: EdgeInsets.all(10.0),
          child: Text("Row $i")),
      onTap: () {
        setState(() {
          widgets.add(getRow(widgets.length + 1));
          print('row $i');
        });
      },
    );
  }
Durdu
  • 4,649
  • 2
  • 27
  • 47
6

You can also use animatedlist widget for animations. code example are given in the following link.

AnimatedList

Md. Yeasin Sheikh
  • 54,221
  • 7
  • 29
  • 56
MRizwan33
  • 2,723
  • 6
  • 31
  • 42