Skip to content

Instantly share code, notes, and snippets.

@eseidelGoogle
Created July 7, 2021 20:55
Show Gist options
  • Save eseidelGoogle/49c27f86409b51b03a2a7b157be3b206 to your computer and use it in GitHub Desktop.
Save eseidelGoogle/49c27f86409b51b03a2a7b157be3b206 to your computer and use it in GitHub Desktop.
Why do generic methods get treated like dynamic, but functions dont?
class Test<T> {
Future<T?> method() {
return Future.value(null);
}
}
Future<T?> function<T>() {
return Future.value(null);
}
void main() async {
Test test = Test<bool>();
bool foo = await test.method(); // Analyzer thinks this returns Future<dynamic>
bool bar = await function<bool>(); // Analyzer knows this returns Future<bool?>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment