Comments (5)
Ok after further testing, I can see it's related to a Dialog.
I have a button to display a Dialog like this:
showDialog<bool>(
context: context,
builder: (BuildContext context) => AlertDialog(
actions: <Widget>[
FilledButton(
onPressed: () async {
await context.popRoute();
// this is a Riverpod call to delete an item from the database
ref
.read(installationEditControllerProvider(
widget.installationId)
.notifier)
.deleteInstallation(widget.installationId);
}),
child: Text('Delete'),
],
),
);
And in another part of the widget I detect the Riverpod response after the item is deleted to redirect to another page. At this point, if I just do a context.navigateTo(const InstallationsRoute());
it doesn't work but if I do a small pause like the following, then it works:
Future.delayed(const Duration(milliseconds: 200), () => context.navigateTo(const InstallationsRoute()));
It seems related to the time it takes to close the Dialog. The problem is even if I wait like this await context.popRoute();
it doesn't work, I must put a small delay anyway.
Future<void> doInstallationDeleted(BuildContext context) async {
await Future(() async {
// IT WORKS
// Future.delayed(const Duration(milliseconds: 200),
// () => context.navigateTo(const InstallationsRoute()));
// IT DOESN'T WORK
// context.navigateTo(const InstallationsRoute());
});
}
What's the correct way to deal with showDialog()
and auto_route?
Thanks.
from auto_route_library.
I also found this issue; this is because navigateTo is asynchronous !
from auto_route_library.
Hi @tomlezen
So how to deal with it? I realised that and tried to await context.navigateTo(const InstallationsRoute());
but nothing changes
Thanks.
from auto_route_library.
Hi @tomlezen
So how to deal with it? I realised that and tried to
await context.navigateTo(const InstallationsRoute());
but nothing changesThanks.
You can try to use:context.popForced
from auto_route_library.
Thanks @tomlezen
This seems to work for the Dialog. Anyways I am also facing some other issues when combining navigateTo() with didPopNext(), I was trying to just invalidate a Riverpod provider in the didPopNext() method to refresh some data but it's not always working the same way so I have to manually call ref.invalidate() before navigateTo() to ensure it works as expected.
Thanks again.
from auto_route_library.
Related Issues (20)
- Issue with easy_localization when using AutoTabsScaffold with Auto Route HOT 1
- Erro de null ao navegar para um filho de um AutoTabsRouter.pageView HOT 1
- How to get redirectFrom for a guard redirection HOT 2
- Deeplink builder does not working
- browser refresh issue HOT 1
- App crashes when trying to navigate from modal, which is animating. HOT 1
- Udpate documentation for Autoroute Declaritive Routing HOT 1
- Redirect is not working in `AutoRouteGuard` HOT 8
- Navigate Function causes clearing for path params HOT 1
- AutoLeadingButton custom semantic label
- onNavigation guard causes Stack Overflow
- In NESTED NAVIGATION the pages overlap in the transition HOT 2
- infinite loop on context.router.pop() HOT 1
- AutoTabsRouter testecase fail. HOT 4
- Initial page created when homeIndex is set differently
- add shallow routing
- Functionality to control route changes
- Functionality to control route changes HOT 4
- Unhandled Exception: type 'AutoRoutePage<dynamic>' is not a subtype of type 'AutoRoutePage<Object>' in type HOT 2
- Inherited params not working and wrong navigation HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from auto_route_library.