You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi. I'm having a problem with using Riverpod and GoRouter.
My app need to have dynamic pages based on value i retrieved from the API. That mean if the API result page length is 16, my app will have only 16 pages. So that mean i cannot configured static route.
So i decided to go with this way. First i created a route state that will hold all the GoRoute as a list.
@Riverpod(keepAlive: true)
class RouteState extends _$RouteState {
@override
List<GoRoute> build() {
return [];
}
Future<bool> updateGoRoutePath() async {
final deviceModelService = ref.read(deviceModelServiceProvider);
final result = await deviceModelService.createRoutesList();
state = result;
return result.isNotEmpty;
}
}
Which will inject the route back into the main GoRoute pages that need the routes list.
if canTest is true. Then proceed to the next page, is my desired behavior. But apparently whenever RouteState changes. it rebuilt AppRouter state as well. Which mean as soon as await routeState.updateGoRoutePath(); finished. My MainApp routerConfig rebuild itself.
And thus it will stay in the first page. Basically nothing happen. So now i'm completely stuck. How should i approach this issue differently. Can anyone guide me?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi. I'm having a problem with using Riverpod and GoRouter.
My app need to have dynamic pages based on value i retrieved from the API. That mean if the API result page length is 16, my app will have only 16 pages. So that mean i cannot configured static route.
So i decided to go with this way. First i created a route state that will hold all the GoRoute as a list.
Which will inject the route back into the main GoRoute pages that need the routes list.
The routes list will be created by my button widget.
if
canTest
is true. Then proceed to the next page, is my desired behavior. But apparently wheneverRouteState
changes. it rebuilt AppRouter state as well. Which mean as soon asawait routeState.updateGoRoutePath();
finished. My MainApp routerConfig rebuild itself.And thus it will stay in the first page. Basically nothing happen. So now i'm completely stuck. How should i approach this issue differently. Can anyone guide me?
Beta Was this translation helpful? Give feedback.
All reactions