1

Say, I have this:

VoidCallback callback;

It can only be called if it isn't null, so for that I am doing:

if (callback != null) callback();

Is there any shorthand similar to this?

callback?.();
iDecode
  • 22,623
  • 19
  • 99
  • 186

1 Answers1

5

Thanks to @jamesdlin, the solution is:

VoidCallback callback;
callback?.call();
iDecode
  • 22,623
  • 19
  • 99
  • 186