Make FlutterErrorDetails.exception non-nullable as documented (#67364)

This commit is contained in:
Michael Goderbauer
2020-10-05 18:07:02 -07:00
committed by GitHub
parent 1271447bbe
commit 8998167d0f
21 changed files with 46 additions and 47 deletions

View File

@@ -28,7 +28,7 @@ Future<void> main() async {
completer.future.then(
(String value) {},
onError: (dynamic error, StackTrace stack) {
onError: (Object error, StackTrace stack) {
assert(stack is stack_trace.Chain);
FlutterError.reportError(FlutterErrorDetails(
exception: error,

View File

@@ -10,7 +10,7 @@ import 'package:flutter_test/flutter_test.dart';
Future<void> main(FutureOr<void> testMain()) async {
reportTestException = (FlutterErrorDetails details, String testDescription) {
expect(details.exception, isA<StateError>());
expect(details.exception.message, 'foo');
expect((details.exception as StateError).message, 'foo');
expect(testDescription, 'custom exception reporter');
};

View File

@@ -737,7 +737,7 @@ void main() {
}, () {});
expect(flutterErrorDetails.exception, isA<AssertionError>());
expect(flutterErrorDetails.exception!.message, 'A Timer is still pending even after the widget tree was disposed.');
expect((flutterErrorDetails.exception as AssertionError).message, 'A Timer is still pending even after the widget tree was disposed.');
});
});
}