dart-lang/dart-pad

`Future<void> main() async ...` fails on dartpad if flutter is imported

Closed this issue · 1 comments

What happened?

DartPad is failing to compile a program if the return type of main is anything other than void, or dynamic, AND flutter is imported. It does not cause an error if flutter is not imported.

Steps to reproduce problem

Run example code below.

Additional info

Browser

Browser: Google Chrome

Version: Version 124.0.6367.201 (Official Build) (arm64)

Are you using any extensions/plugins that affect website behavior
(particularly those that affect iframes, such as ad blockers)?

Are there any warnings or errors in your browser's JavaScript console?
If so, paste them below:

main.dart.js:92261 
        
        
       POST https://stable.api.dartpad.dev/api/v3/compileDDC 400 (Bad Request)

Machine

Operating system: macOS

Version: 14.5 (23F79)

Your code

What code was in the editor, if any, when the failure occurred? You
can paste it in below:

import 'package:flutter/material.dart';

Future<void> main() async => print('Hello World!');

DartPad's output

Did DartPad print anything to the console pane? If so, paste it below:

compileDDC
main.dart:12:25: Error: Can't return a value from a void function.
      return entrypoint.main();
                        ^

If you were running Flutter code, you can also paste an image of the
Flutter output directly into this bug report.

I suspect removing the return keyword from this line of code would solve the issue.