-
-
Notifications
You must be signed in to change notification settings - Fork 298
how to setup Upgrader in GoRouter with routerDelegate. #323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@ShubhalaxmiSarwate , did you find a solution for this issue? I am facing the same problem. |
Facing the same problem.
@larryaasen , any idea how to solve this issue ? |
hallo @d76g , |
I might fix this problem. The following is my solution. (Sorry if my English is not good.) First (couldn't solve)I moved Upgrader to static. Like below: static final _upgrader = Upgrader(
dialogStyle: Platform.isIOS
? UpgradeDialogStyle.cupertino
: UpgradeDialogStyle.material,
debugLogging: true
debugDisplayOnce: true,
);
@override
Widget build(BuildContext context, WidgetRef ref) {
final router = ref.watch(routerProvider);
return MaterialApp.router(
...
builder: (context, child) {
return UpgradeAlert(
navigatorKey: router.routerDelegate.navigatorKey,
upgrader: _upgrader,
child: child,
);
},
);
} Then sometimes UpgradeAlert showed, but sometimes didn't show. ConclusionI used UpgradeCard to solve adobe problem. import 'package:flutter/material.dart';
import 'package:otomo/views/bases/screens/screen_barrier.dart';
import 'package:upgrader/upgrader.dart';
class UpgradeModal extends UpgradeCard {
UpgradeModal(
{Key? key, Upgrader? upgrader, margin = const EdgeInsets.all(4.0)})
: super(key: key, upgrader: upgrader, margin: margin);
@override
Widget buildUpgradeCard(BuildContext context, UpgradeBaseState state) {
return ScreenBarrier(
child: Center(child: super.buildUpgradeCard(context, state)),
);
}
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
static final _upgrader = Upgrader(
dialogStyle: Platform.isIOS
? UpgradeDialogStyle.cupertino
: UpgradeDialogStyle.material,
debugLogging: true,
debugDisplayOnce: true,
);
@override
Widget build(BuildContext context) {
return MaterialApp.router(
...
builder: (context, child) {
return Stack(
children: [
child!,
UpgradeModal(
upgrader: _upgrader,
margin: const EdgeInsets.symmetric(horizontal: 20),
),
],
);
},
);
}
} |
facing same issue . can u please fix this ? |
Issue most likely rises from the Future.delayed fixes larryaasen#323
how to implement Upgrader in MaterialApp.router with routerDelegate. i tried using the below code but no alert popped up.
Then i tried implementing the Upgrader in my dashboard page(base of stack). whenever a page is pushed or popped in the stack using GoRouter.of(context).push or context.pop() or context.go(), then all the pages in the stack are rebulit and the alert pops up again on the page which is on the top of stack.
I only want to display the alert on the dashboard of my application. Could someone please help me with this issue?
The text was updated successfully, but these errors were encountered: