Unverified Commit 42d3464d authored by Dan Field's avatar Dan Field Committed by GitHub

Let `sliver.dart` `_createErrorWidget` work with other Widgets (#30880)

Credit to @ymback
parent 2736c8c1
...@@ -1291,8 +1291,8 @@ class KeepAlive extends ParentDataWidget<SliverWithKeepAliveWidget> { ...@@ -1291,8 +1291,8 @@ class KeepAlive extends ParentDataWidget<SliverWithKeepAliveWidget> {
} }
} }
// Return an ErrorWidget for the given Exception // Return a Widget for the given Exception
ErrorWidget _createErrorWidget(dynamic exception, StackTrace stackTrace) { Widget _createErrorWidget(dynamic exception, StackTrace stackTrace) {
final FlutterErrorDetails details = FlutterErrorDetails( final FlutterErrorDetails details = FlutterErrorDetails(
exception: exception, exception: exception,
stack: stackTrace, stack: stackTrace,
......
...@@ -195,4 +195,19 @@ void main() { ...@@ -195,4 +195,19 @@ void main() {
expect(find.text('B'), findsNothing); expect(find.text('B'), findsNothing);
expect(find.text('BOTTOM'), findsOneWidget); expect(find.text('BOTTOM'), findsOneWidget);
}); });
testWidgets('Can override ErrorWidget.build', (WidgetTester tester) async {
const Text errorText = Text('error');
final ErrorWidgetBuilder oldBuilder = ErrorWidget.builder;
ErrorWidget.builder = (FlutterErrorDetails details) => errorText;
final SliverChildBuilderDelegate builderThrowsDelegate = SliverChildBuilderDelegate(
(_, __) => throw 'builder',
addAutomaticKeepAlives: false,
addRepaintBoundaries: false,
addSemanticIndexes: false,
);
expect(builderThrowsDelegate.build(null, 0), errorText);
expect(tester.takeException(), 'builder');
ErrorWidget.builder = oldBuilder;
});
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment