I just tried the following in DartPad:
void main() { int? x; }
and get the following error:
Error compiling to JavaScript
For me, removing pubspec.lock and rerun fix the issue. I was importing the project from Windows to Mac.