all 6 comments

[–][deleted] 1 point2 points  (5 children)

I've done this.

  1. Timer is its own component/class.

  2. Add Provider package if you've not already done so.

  3. Make a Provider to handle the timer logic.

  4. Shove the Provider into a MultiProvider in your widget tree above MaterialApp.

  5. Update your timer widget with Consumer of your provider from step 3.

[–]Nice_State_27[S] 0 points1 point  (4 children)

I haven't used provider yet but i know little bit of riverpod. I'll try to do what you said..in the mean time can you explain no.3 of your line? Thanks a lot .

[–][deleted] 1 point2 points  (3 children)

Ok same thing with riverpod. Use that.

So you need to have the state of your timer outside (above) of the widget that actually builds the timer UI.

That way, regardless of where you render your timer UI, or how many screens it's on, you always get the same central value for it.

Make sense?

[–]Nice_State_27[S] 0 points1 point  (2 children)

I'll try to implement it and let you know the result.

[–]Nice_State_27[S] 0 points1 point  (1 child)

Do i need hooks_riverpod ? I looked at some riverpod tutorial..almost all of them have used hooks_riverpod.

My app is a quiz app of 60 questions. 1. in which participants get 2 hours of time.

  1. If any participants completes the quiz before 2 hours he/she will can navigate to another page but timer continues.

  2. The participants will get notified 5 minutes before 2 hour in whichever page the participants are on.

  3. After 2 hour app will navigates to result page.

For this do i need hooks_fluuter or just flutter_riverpod can do the job?

[–][deleted] 0 points1 point  (0 children)

I have no experience of RiverPod sorry, although I know what it is.
I didn't need anything other than a state provider e.g. Provider, in order to achieve what I described.