Why List() constructor is not accessible in Dart's null safety?
问题 With NNBD, you're not allowed to initialise the list using the default constructor: List<int> foo = List(); // Compile time error However, you can still do: List<int> foo = []; // No error So, what's the difference between the two? Either both of them should show the error or none of them. 回答1: The List constructor had two uses: new List() to create an empty growable list, equivalent to [] . new List(n) to create a fixed-length list of length n filled with null values With null safety, the