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> {
}
}
// Return an ErrorWidget for the given Exception
ErrorWidget _createErrorWidget(dynamic exception, StackTrace stackTrace) {
// Return a Widget for the given Exception
Widget _createErrorWidget(dynamic exception, StackTrace stackTrace) {
final FlutterErrorDetails details = FlutterErrorDetails(
exception: exception,
stack: stackTrace,
......
......@@ -195,4 +195,19 @@ void main() {
expect(find.text('B'), findsNothing);
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