Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
mmcdon20 opened this issue May 13, 2024 · 1 comment · Fixed by #2969
Closed

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

mmcdon20 opened this issue May 13, 2024 · 1 comment · Fixed by #2969
Labels
P3 A lower priority bug or feature request

Comments

@mmcdon20
Copy link
Contributor

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.

@mmcdon20
Copy link
Contributor Author

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

@johnpryan johnpryan added the P3 A lower priority bug or feature request label May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 A lower priority bug or feature request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants