I just tried the following in DartPad:
void main() { int? x; }
and get the following error:
Error compiling to JavaScript
Add the following line to the analysis_options.yaml
analyzer: enable-experiment: - non-nullable