I am trying to assign a List of String in flutter like:
List<String> names = ["A", "B", "C"];
error: The type 'List' is declared with 0 type parameters, but 1 type arguments were given. (wrong_number_of_type_arguments at line 90
error: A value of type 'List' can't be assigned to a variable of type 'List'. (invalid_assignment at line 90
Why can't I assign a List like this? What am I doing wrong here? I have tried:
String a = "A";
String b = "B";
String c = "C";
List<String> names = [a, b, c];
It is still shwoing the same error.
I don't understand.
You need to declare an empty list with a name first and then later add values to the list. Using listName.add()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.