I'm relatively new to Dart and Flutter and I'm running in a basic error I'm not able to fix at the moment.
I get the following error in VS Code:
String isn't a type.dart(not_a_type)
That's my code snippet:
[String] getIntArrayFor({PurposeEnum purpose, String categoryName}){
switch(purpose){
case PurposeEnum.somePurpose:
return [];
default:
return [];
}
}
The error is marked at both String keywords in the function header.
Does anybody have an idea how to fix that?
if you want your method to return an array replace [String] with List<String>:
List<String> getIntArrayFor({PurposeEnum purpose, String categoryName}){
switch(purpose){
case PurposeEnum.somePurpose:
return <String>[] ;
default:
return <String>[] ;
}
}
You can find more information about dart lists (which are the equivalent of arrays in other languages) in this official flutter docs link.
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