Let sliver.dart
_createErrorWidget
work with other Widgets (#30880)
Credit to @ymback
This commit is contained in:
parent
2736c8c19f
commit
42d3464d2e
@ -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() {
|
|||||||
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;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user