Skip to main content

Flutter Dart Create Growable List Unlimited Items List

In today's tutorial we will create a Growable List consider as unlimited items list in dart. We will add as many items as we want in List and also can replace any item using Index position.

Flutter Dart Create Growable List Unlimited Items List

Flutter Dart Create Growable List Unlimited List

1. Creating a List and defining it's type. I am creating String data type list. Though all the data we insert in the list should be in String type.
 final fullList = <String]>['A'];
2. We will replacing the Zero index number item with index position method.
 // To Replace Item.
  fullList[0] = 'B';
3. We will add more items into List with Add method.
  // To Add Item.
  fullList.add('C');
  fullList.add('D');
Source code:
 void main() {
  
 final fullList = <String>['A'];
  
  // To Replace Item.
  fullList[0] = 'B';
  
  // To Add Item.
  fullList.add('C');
  fullList.add('D');
  
  print(fullList);

}
Output:

Comments