Comments (8)
you need to set a refreshListenable as per the README
from go_router.
Is that required? I can't seem to find where in the documentation is says it's required, and it shows and example of using the redirect without refreshListenable. Even so, I tried adding a refreshListenable and still get the same behavior.
from go_router.
You're right -- you don't have to use a refreshListenable
if you're manually navigating.
You've got a redirect loop:
Exception: Redirect loop detected: / => /login => /login
You can see it if you show the exception in your error page:
errorPageBuilder: (context, state) => MaterialPage<void>(
key: state.pageKey,
child: Scaffold(
body: Text(state.error.toString()),
),
),
Redirection is called repeatedly until a null
is returned. This allows for multiple route redirections, etc. before landing at the desired page, which in turn allows for routes in an app to build up over time, keeping the old routes but redirecting them to the new ones.
from go_router.
Oh I see, thanks! I like that. This would be super helpful to point out directly in the documentation. I didn't realize that the redirect function would run until it returns null.
from go_router.
Ha. Way ahead of you. The README in the repo is already updated and it'll be updated on pub.dev on the next release. The next release will also include exception info in the debug output in the case that you've got route debugging turned on. Your questions and feedback have been super helpful.
How's your use case? Are things working they way you want?
from go_router.
Sweet!
I'm now trying to figure out how to initialize my app correctly. I'm having some complications when it comes to when/how to load a stored api key BEFORE the go_router attempts to run the redirect function and begin routing. It's tricky because the loading of the api key is asynchronous.
I'm also having this really annoying issue of not being able to hot reload my app. Whenever I make changes, the screen goes white and refuses to come back, even if I manually refresh the browser. Not ready to blame that on go_router though.
It would be cool if go_router had some kind of built in paradigm for initializing auth state to avoid these async/init headaches. Not sure if that's possible though.
from go_router.
You can do async init before even running your app, e.g.
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(MyApp());
}
Of course, you can bake auth init into how you route, too, and use it as input for redirection.
from go_router.
Yeah, tried that strategy but still having some hangups. Maybe I'm screwing something up though.
from go_router.
Related Issues (20)
- Handle `errorBuilder` with Error Type HOT 5
- Please what tools did you use to build docs please share! HOT 1
- modal bottom sheet route
- Working With SPA in GoRouter HOT 1
- [Feature] allow push, pop, go operations in redirect callback HOT 2
- Fix nested navigation between multiple screen HOT 3
- Add the ability to hide/unhide CupertinoTabBar when GoRouter is used HOT 1
- Support for flutter_riverpod HOT 4
- Any thoughts on implementing "MiddleWare" to support deferred libraries? HOT 1
- Why is there an initialLocation but not a initialNamedLocation? HOT 1
- go Directly to books/new (tab child)
- Persistent context between routes HOT 1
- Unique PageKey doesn't work HOT 1
- Broken navigation behaviour on shared scaffold example. HOT 1
- How to deal with different navigation architectures on phones and tablets/web?
- Extra value is null when Widget inspector is open
- UrlPathStrategy.path is causing hot-reload in web
- redirect without page stack
- how to redirect without pushing
- Navigation rail in books example is not persistent
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 go_router.