-
-
Notifications
You must be signed in to change notification settings - Fork 134
ProgressDialog won't show again when coming back from a previous screen. #54
Comments
@rhyscoronado please share some code through which we can replicate the issue. |
Also @rhyscoronado @xsahil03x , we have the dialog configured as to use the @rhyscoronado are you trying just to |
`
}` That's the part of the project code being executed that triggers the error log I posted earlier. So after going to the Traffic Page Route, I just pop that Traffic Page with a result. |
I am having same issue. From my drawer I navigate to Profile page When I pop the Profile page using back nav button (pop) I Just modified the lib files to show error as String, hence my error looks different.
|
When you pop, as You can have something like, |
I don't think the problem was resolved on my situation compared to the latter who commented 23 hours ago. If you can, what's wrong with the code I posted? |
void routeTraffic() async {
pr.style(message: 'Loading accurate location...');
await pr.show();
final currentLocation = await Location().getLocation();
// here you are hiding the dialog
await pr.hide();
final result = await Navigator.pushNamed(
context,
TrafficPage.route,
arguments: TrafficPageArgs(
project.id,
LatLng(currentLocation.latitude, currentLocation.longitude),
widget.project,
),
); after hiding the dialog, how can you expect it to show? |
But, once the routeTraffic() is recalled the dialog should show. |
can you please share the complete code to reproduce? |
Ok So I was able to find the issue causing scenario. I tried to replicate the issue with a simple code. So I use drawer from home page to navigate to profile page. But when I took the test code more closer to my actual code. Here is the learning My Code import 'package:flutter/material.dart';
import 'package:progress_dialog/progress_dialog.dart';
import 'drawer.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
Widget build(context) {
return MaterialApp(
title: 'PDTest',
initialRoute: '/home',
routes: {
'/home': (context) {
return HomePage();
},
'/profile': (conetxt) {
return ProfilePage();
},
},
);
}
}
class HomePage extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
ProgressDialog _pr = ProgressDialog(
context,
type: ProgressDialogType.Normal,
isDismissible: false,
);
return Scaffold(
appBar: AppBar(
title: Text('Home Page'),
),
drawer: drawerMenu(context),
body: Center(
child: Text('Home Page'),
),
);
}
}
class ProfilePage extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
ProgressDialog _pr = ProgressDialog(
context,
type: ProgressDialogType.Normal,
isDismissible: false,
);
return Scaffold(
appBar: AppBar(
title: Text('Profile Page'),
),
body: Center(
child: Text('Profile Page'),
),
);
}
} drawer.dart import 'dart:async';
import 'package:flutter/material.dart';
import 'package:progress_dialog/progress_dialog.dart';
Widget drawerMenu(BuildContext context) {
ProgressDialog _pr = ProgressDialog(
context,
type: ProgressDialogType.Normal,
isDismissible: false,
);
return Drawer(
child: ListView(
children: <Widget>[
DrawerHeader(child: null),
ListTile(
title: Text('Profile Page'),
onTap: () async {
await _pr.show();
Timer(Duration(seconds: 3), () async {
if (_pr.isShowing()) await _pr.hide();
Navigator.popAndPushNamed(context, '/profile');
});
},
),
],
),
);
} This is the complete code, you can run and test it. |
Checkout this commit. This will be a temporary solution. Behaviour |
Temporary solution is having same error behavior. So I put the initialization just above the usage. |
I have run the issue_57.dart file and it's working fine |
Isn't it a bad thing to put the initialization of the ProgressDialog inside the
Specially for StatefulWidgets, since they are rebuilt every time, what are we going to do with that? |
Care to look back into this @fayaz07 @xsahil03x @prashant3285 |
well I have added in the latest docs to make it final |
But doesn't that render the progress dialog customizable should you want to update the message or other properties? |
Describe the bug
Screen with ProgressDialog loading a content, after the content loads, the ProgressDialog is hidden and it moves to the next screen, when you pop back to that screen, and when you try to show the ProgressDialog again, it doesn't show.
Expected behavior
Should show without error
Log
flutter: Exception while showing the dialog [VERBOSE-2:ui_dart_state.cc(157)] Unhandled Exception: type 'FlutterError' is not a subtype of type 'String' #0 ProgressDialog.show (package:progress_dialog/progress_dialog.dart:160:18) #1 _ProjectMapPageState.routeTraffic (package:signtracker/feature/project/maps/project_map_page.dart:469:8) #2 _ProjectMapPageState.build.<anonymous closure> (package:signtracker/feature/project/maps/project_map_page.dart:316:46) #3 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:706:14) #4 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:789:36) #5 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24) #6 TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:486:11) #7 BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:264:5) #8 BaseTapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:199:7) #9 PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:467:9) #10 PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:76:12) #11 PointerRouter._dispatchEventToRoutes.<anonymous closure> (package:flutter/src/gestures/pointer_router.dart:117:9) #12 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:379:8) #13 PointerRouter._dispatchEventToRoutes (package:flutter/src/gestures/pointer_router.dart:115:18) #14 PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:101:7) #15 GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:218:19) #16 GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:198:22) #17 GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:156:7) #18 GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:102:7) #19 GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:86:7) #20 _rootRunUnary (dart:async/zone.dart:1138:13) #21 _CustomZone.runUnary (dart:async/zone.dart:1031:19) #22 _CustomZone.runUnaryGuarded (dart:async/zone.dart:933:7) #23 _invoke1 (dart:ui/hooks.dart:273:10) #24 _dispatchPointerDataPacket (dart:ui/hooks.dart:182:5)
Smartphone (please complete the following information):
Device: iPhone5s
OS: iOS.12
flutter
Flutter 1.12.13+hotfix.9 • channel stable • [email protected]:flutter/flutter.git
Framework • revision f139b11009 (3 weeks ago) • 2020-03-30 13:57:30 -0700
Engine • revision af51afceb8
Tools • Dart 2.7.2
The text was updated successfully, but these errors were encountered: