I am trying to create a list using List<E>.generate(length, generator) function but it giving an error The return type Map<String, Dynamic> isn't a string, as defined by anonymous closure.
Here is the code.
List<String> _generateList() {
return List<String>.generate(20, (i) => {"Hello $i"});
}
Error:

List<String> _generateList() {
return List<String>.generate(20, (i) => "Hello $i");
}
Removed the curly brackets in the return statement.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With