Question mark after function parameter in dart

Viewed 857

I am new to dart and flutter, when i am using Stream, i found this function

StreamSubscription<T> listen(void onData(T event)?,
  {Function? onError, void onDone()?, bool? cancelOnError});

Can someone tell me what does the '?' mean here?

1 Answers

As of Dart 2.12, the language supports null safety. Here, ? explicitly states that a variable/parameter may be null.

Learn more here and watch this video

Related