Skip to content

Instantly share code, notes, and snippets.

@RedBrogdon
Last active October 20, 2020 15:12
Show Gist options
  • Save RedBrogdon/cb03c039bd508de3435f04eb791fc5a9 to your computer and use it in GitHub Desktop.
Save RedBrogdon/cb03c039bd508de3435f04eb791fc5a9 to your computer and use it in GitHub Desktop.
Snippet 3: More nullable types!
// Type parameters for generics can also be nullable or
// non-nullable. Try using question marks to correct the
// type declarations of `aNullableListOfStrings` and
// `aListOfNullableStrings`:
void main() {
List<String> aListofStrings = ['one', 'two', 'three'];
List<String> aNullableListOfStrings;
List<String> aListofNullableStrings = ['one', null, 'three'];
print('aListofStrings is $aListofStrings.');
print('aNullableListOfStrings is $aNullableListOfStrings.');
print('aListofNullableStrings is $aListofNullableStrings.');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment