Reputation: 22926
From: https://flutter.dev/docs/cookbook/navigation/passing-data
final todos = List.generate(
20,
(i) => Todo(
'Todo $i',
'A description of what needs to be done for Todo $i',
),
);
This says a type has to be there: https://api.flutter.dev/flutter/dart-core/List/List.generate.html
What is the return type of List.generate of Flutter when no type is specified?
Upvotes: 0
Views: 1353
Reputation: 1865
in this case List.generate
will return List<Todo>
. It is a good practice to give the type of the list.
final todos = List<Todo>.generate(
20,
(i) => Todo(
'Todo $i',
'A description of what needs to be done for Todo $i',
),
);
If you want any object's type just simply use yourobject.runtimeType
Upvotes: 1