File tree 2 files changed +29
-0
lines changed
2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -571,6 +571,17 @@ class _PackagesViewState extends State<_PackagesView> {
571
571
builder: (BuildContext context, BoxConstraints constraints) {
572
572
switch (snapshot.connectionState) {
573
573
case ConnectionState .done:
574
+ if (snapshot.hasError) {
575
+ assert (() {
576
+ FlutterError .reportError (FlutterErrorDetails (
577
+ exception: snapshot.error! ,
578
+ stack: snapshot.stackTrace,
579
+ context: ErrorDescription ('while decoding the license file' ),
580
+ ));
581
+ return true ;
582
+ }());
583
+ return Center (child: Text (snapshot.error.toString ()));
584
+ }
574
585
_initDefaultDetailPage (snapshot.data! , context);
575
586
return ValueListenableBuilder <int ?>(
576
587
valueListenable: widget.selectedId,
Original file line number Diff line number Diff line change @@ -997,6 +997,24 @@ void main() {
997
997
final double appIconBottomPadding = tester.getTopLeft (appPowered).dy - tester.getBottomLeft (appIcon).dy;
998
998
expect (appIconBottomPadding, 18.0 );
999
999
});
1000
+
1001
+ testWidgets ('Error handling test' , (WidgetTester tester) async {
1002
+ LicenseRegistry .addLicense (() => Stream <LicenseEntry >.error (Exception ('Injected failure' )));
1003
+ await tester.pumpWidget (const MaterialApp (home: Material (child: AboutListTile ())));
1004
+ await tester.tap (find.byType (ListTile ));
1005
+ await tester.pump ();
1006
+ await tester.pump (const Duration (seconds: 2 ));
1007
+ await tester.tap (find.text ('VIEW LICENSES' ));
1008
+ await tester.pump ();
1009
+ await tester.pump (const Duration (seconds: 2 ));
1010
+ final Finder finder = find.byWidgetPredicate ((Widget widget) => widget.runtimeType.toString () == '_PackagesView' );
1011
+ // force the stream to complete (has to be done in a runAsync block since it's areal async process)
1012
+ await tester.runAsync (() => (tester.firstState (finder) as dynamic ).licenses as Future <dynamic >); // ignore: avoid_dynamic_calls
1013
+ expect (tester.takeException ().toString (), 'Exception: Injected failure' );
1014
+ await tester.pumpAndSettle ();
1015
+ expect (tester.takeException ().toString (), 'Exception: Injected failure' );
1016
+ expect (find.text ('Exception: Injected failure' ), findsOneWidget);
1017
+ });
1000
1018
}
1001
1019
1002
1020
class FakeLicenseEntry extends LicenseEntry {
You can’t perform that action at this time.
0 commit comments