Skip to content

Instantly share code, notes, and snippets.

@tomaszpolanski
Last active November 9, 2021 17:57
Show Gist options
  • Save tomaszpolanski/e7b0021c22a9c631e0a44c1075011093 to your computer and use it in GitHub Desktop.
Save tomaszpolanski/e7b0021c22a9c631e0a44c1075011093 to your computer and use it in GitHub Desktop.
Null safe
final String? text;
@override
Widget build(BuildContext context) {
final _text = text; // Assign field to local final variable
return Column(
children: [
if (_text != null) Text(_text), // The `!` is not longer needed
],
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment