Fix FlutterError.onError in debug mode (#53843)

* Fix FlutterError.onError in debug mode

* update

* fix comments

* add license header

* fix analyzer

* update

* another attempt

* fix test

* fix comment
This commit is contained in:
chunhtai
2020-04-22 17:17:42 -07:00
committed by GitHub
parent 900c7c166b
commit d35671c6d1
7 changed files with 115 additions and 11 deletions

View File

@@ -572,9 +572,9 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
}) {
assert(description != null);
assert(inTest);
_oldExceptionHandler = FlutterError.onError;
_oldExceptionHandler = FlutterError.presentError;
int _exceptionCount = 0; // number of un-taken exceptions
FlutterError.onError = (FlutterErrorDetails details) {
FlutterError.presentError = (FlutterErrorDetails details) {
if (_pendingExceptionDetails != null) {
debugPrint = debugPrintOverride; // just in case the test overrides it -- otherwise we won't see the errors!
if (_exceptionCount == 0) {
@@ -800,7 +800,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
/// Called by the [testWidgets] function after a test is executed.
void postTest() {
assert(inTest);
FlutterError.onError = _oldExceptionHandler;
FlutterError.presentError = _oldExceptionHandler;
_pendingExceptionDetails = null;
_parentZone = null;
buildOwner.focusManager = FocusManager();