Flutter: List is deprecated?

Ok found it, it's just how to instantiate it:

List<MyClass> _files = [];

Edit: maybe the most common ones, a bit more detailed according to the docs:

Fixed-length list of size 0

List<MyClass> _list = List<MyClass>.empty();

Growable list

List<MyClass> _list = [];
//or
List<MyClass> _list = List<MyClass>.empty(growable: true);

Fixed length with predefined fill

int length = 3;
String fill = "test";
List<String> _list =  List<String>.filled(length ,fill , growable: true);
// => ["test", "test", "test"]

List with generate function

int length = 3;
MyClass myFun(int idx) => MyClass(id: idx);
List<MyClass> _list = List.generate(length, myFun, growable: true); 
// => [Instance of 'MyClass', Instance of 'MyClass', Instance of 'MyClass']

List<MyClass> myList = <MyClass>[];

From:

_todoList = new List();

Change to:

_todoList = [];

Tags:

Dart

Flutter