Home > Back-end >  What is the use of "?" with datatypes in dart functions (bool?)?
What is the use of "?" with datatypes in dart functions (bool?)?

Time:12-19

While learning dart I came across this line in https://dart.dev/guides/language/language-tour#functions

/// Sets the [bold] and [hidden] flags ...
void enableFlags({bool? bold, bool? hidden}) {...}

Can someone explain the use of the question marks after datatype (bool?)

CodePudding user response:

This is with null safety, the question mark means that this bool? can possibly be null and flutter will allow you to assign null to it. String can never be null and you'll get an error before compiling.

It is a pretty big thing in Dart, so you better learn it from the official documentation

  • Related