Dart List — Code Snippets Part 1

This article will give you the most important List Code Snippets. The full documentation can be found from api.flutter.dev website.

What is List in Dart?

An indexable collection of objects with a length is called List.

Dart List having commonly have two different type kinds.

  1. Fixed length — The Dart will give you an error when you try to change the length of the list.
  2. Dynamic length (growable length)

Okay. Lets jump in to the code snipits.


  1. List.empty({bool growable: false})

2. List.filled(int length, E fill, {bool growable: false})

3. List.from(Iterable elements, {bool growable: true})

4. List.generate(int length, E generator(int index), {bool growable: true})

5. List.unmodifiable(Iterable elements)


  1. first

2. isEmpty

3. last

4. reversed

5. length


I hope this article will help you to quickly understand and get to know about constructors and the properties of List. The Part 2 will contain the methods of List. Once the Part 2 get published this article will be updated soon.

This Code Snippets can be found from GitHub: https://github.com/Achsuthan/FlutterCodeSnippets/tree/main/DartList

Thanks for reading this article. Please leave claps if you find it useful! And I will be happy to hear any feedback.

Follow me on LinkedIn: www.linkedin.com/in/achsuthanmahendran




iOS Developer, Web Developer, Flutter Developer. GitHub: achsuthan

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Zoom Web Client SDK HTML5/JavaScript/PHP Example

CodeWars: Descending order

Exploring .NET Core 3.0. What’s New?

How to implement camera Capture and save Image using Jetpack compose

11/16/2020 6:47PM

AWS EKS Configure & Access Kubernetes Dashboard

Introduction to Reactive Programming

Find maximum contiguous subarray in O(n) time without sorting

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Achsuthan Mahendran

Achsuthan Mahendran

iOS Developer, Web Developer, Flutter Developer. GitHub: achsuthan

More from Medium

Using themes in Flutter

Use themes in Flutter

Communicate Between Flutter and Native Android and iOS Code Using Platform Channel

Person on laptop

The Frosted Floating Bottom Bar in Flutter

Create a real-time chat with pure Flutter and Dart