-4

My old working code: List<List<T>> pages = List<List<T>>();

Now doesn't work with null safety:

The default 'List' constructor isn't available when null safety is enabled. Try using a list literal, 'List.filled' or 'List.generate'.dartdefault_list_constructor 'List' is deprecated and shouldn't be used. Use a list literal, [], or the List.filled constructor instead.

manafire
  • 5,984
  • 4
  • 43
  • 53
  • 1
    The error you posted mentions the solution. More in-depth explanation in the official docs here: https://dart.dev/tools/diagnostic-messages#default_list_constructor – Stephen Apr 17 '21 at 15:51
  • In your case you would want to use `List> pages = [[]];` or perhaps even just `var pages = [[]]` – Stephen Apr 17 '21 at 15:54

1 Answers1

1
// @dart=2.12
void doSomething<T>() {
  List<List<T>> pages = [];
  print(pages.runtimeType.toString());
}

void main() {
  doSomething<String>();
}

Result

JSArray<List<String>>