Execute custom function before navigating; add parameters to Route #1984
Closed
matthew-nm
started this conversation in
General
Replies: 2 comments 2 replies
-
@matthew-nm have you tried doing your login inside of a route guard? |
Beta Was this translation helpful? Give feedback.
1 reply
-
@matthew-nm I highly recommend that you pass the ref to the Guard's constructor, and yes you can access the args of the guarded route using |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, I have a page in my app that works best if the state (via riverpod) is set before navigating. This code is synchronous. Currently, I have the logic execute in my button call just before calling the router, but I feel like this method is error-prone because I could easily forget to call the state logic.
Is it possible to:
ref
andnote
objects for the custom function to use?If so, I would then call the route as,
My first thought was to simply do the state initialization within the NoteFormPage, but you aren't allowed to do
ref.read(....notifer).func(...)
within a widget's build cycle. My next thought was to use aFutureBuilder
or riverpodAsyncValue
, but both of these are async resolvers that I can't quite get to work right but also would draw some loading frames first which is unnecessary and feels janky given that the code I'm executing is synchronous (I already have the data from the previous page, just need to set the states).Thanks for any help or suggestions!
Beta Was this translation helpful? Give feedback.
All reactions