Created
April 4, 2019 08:22
-
-
Save kikuchy/9fe3b219a66d198ac160f885463a48b3 to your computer and use it in GitHub Desktop.
Is there any static code analyzer for Dart to detect Future#then's onError arguments?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
Future(() => throw Exception()) | |
.then((i) => print(i), | |
// Statically, no issues found. But it causes RUNTIME error 👇 | |
// | |
// Uncaught Error: TypeError: Closure 'main_closure1': type '() => void' is not a subtype of type '(Object) => dynamic' | |
onError: () => print("foo")); | |
Future(() => throw Exception()) | |
.then((i) => print(i), | |
// Of course, no runtime error if onError has one or two arguments. | |
onError: (e) => print(e)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment