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
Better error message when adding Futures into the widget tree #15203
Comments
Did the analyzer not report any issues? |
Unfortunately nothing @Hixie . I am using VS Code with the flutter plugin and then tried with Android Studio. I ran the example just now and opened the Dart Analysis but it reported no problems at all. I hope this helps |
Oh, I see. It's because you declared In the coming months we'll turn on more inference and more strict checking and eventually this will get caught by the analyzer because the inferred return type ( |
Properly specifying the return type will trigger an analyzer error: import 'package:flutter/material.dart';
import 'dart:async';
class Report extends StatelessWidget {
Future<String> makeRequest() async {
try {
return 'OK';
} catch (exception) {
return 'OH NO!';
}
}
@override
Widget build(BuildContext context) {
return new Text(makeRequest());
}
} Not sure what we can do on the Flutter side to make this better? |
Found in Complete sample code
Logs
flutter doctor -v
|
Reproducible as of stable 3.0.1 and master 3.1.0 if the return type of widget is not specified (It is assumed to be logs
flutter doctor -v (mac)
|
EDIT: It seems I must use setState() for it to work. Not directly returning from the async function. But still I think a better error message is needed.
Steps to Reproduce
Logs
Logs
Flutter Doctor
The text was updated successfully, but these errors were encountered: