Illustration by Katerina Limpitsouni

How we can map a Dart list in Flutter? Before doing that, we need to know one thing first.

Flutter layout widgets like Column, Row, or Wrap always has children that returns a List. Not a Map. As a result, we need to tweak our code.

As a result, in some circumstances, we need to map a dart list in flutter as per our requirements.

We have a lot of articles on Flutter List and Map, however, we need to understand the relationship between Dart List and Map in flutter.

Let us first see, how we can map a list in pure dart console programming.

Let us have a Student class:

class Student {   String name;   int age;    Student({     required this.name,     required this.age,   }); }

And, we can create a List of some Student objects in Dart.

List<Student> students = [   Student(     name: 'John',     age: 10,   ),   Student(     name: 'Json',     age: 11,   ),   Student(     name: 'Allen',     age: 9,   ),   Student(     name: 'Maria',     age: 8,   ),   Student(     name: 'Becky',     age: 10,   ), ];

Now, how do we map that list in a flutter app?

We can get an idea from a Dart Console application first.

To read more please visit the following Link.


This free site is ad-supported. Learn more