Use WidgetRef
in singleton to avoid amount of changes
#1294
Unanswered
LeGoffMael
asked this question in
Q&A
Replies: 1 comment
-
Is it that bad practice ? 😅 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
First of all, thank you very much Rémi for your incredible work and support to the flutter community.
I recently finished migrating my flutter application from riverpod
0.13.11
to the latest version. Even though it is now done, I am a little annoyed by the amount of changes this migration required due to the new references to theref
parameter.I would really like to understand where I could reduce its use to only provide it when I really need it.
For example, I am using riverpod in both router and services to secure authenticates routes or logout user.
so instead of providing
ref
to my custom router as suchI thought it would be a good idea to simply change the
MyRouter
class to a singleton, and provideWidgetRef
at init.in this case, i won't need to change all my widgets to
ConsumerWidget
orConsumerStatefulWidget
when they only include a call toMyRouter
for example.I tested it manually a bit and it worked fine.
But since I couldn't find any mention of this usage, is this a bad practice? If so, do I have no choice but to update all my routers and service calls 😢 ?
Beta Was this translation helpful? Give feedback.
All reactions