Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarification needed on automatic routing on state change #111

Open
Lewynation opened this issue Aug 8, 2023 · 0 comments
Open

Clarification needed on automatic routing on state change #111

Lewynation opened this issue Aug 8, 2023 · 0 comments

Comments

@Lewynation
Copy link

I am using flutter bloc for state management and flow builder for routing, just like it has been used in the flutter news toolkit provided by the flutter team.
I expect routing to be handled automatically by flow builder once state changes, however that is not the case in my scenario. Below are code snippets of my setup. What could i be doing wrong?

The Flowbuilder widget:

class AppView extends StatelessWidget {
  const AppView({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: AppTheme().themeData,
      darkTheme: AppDarkTheme().themeData,
      themeMode: ThemeMode.system,
      debugShowCheckedModeBanner: false,
      home: AuthenticatedUserListener(
        child: FlowBuilder<AppStatus>(
          state: context.watch<AppBloc>().state.status,
          onGeneratePages: onGenerateAppViewPages,
        ),
      ),
    );
  }
}

Then the ongenerate pages function:

List<Page<dynamic>> onGenerateAppViewPages(
  AppStatus state,
  List<Page<dynamic>> pages,
) {
  print("Appstate changed");
  switch (state) {
    case AppStatus.onboardingRequired:
      return [OnboardingPage.page()];
    case AppStatus.unauthenticated:
      return [LoginPage.page()];
    case AppStatus.authenticated:
      print("OBJECT: HOME PAGE");
      return [HomePage.page()];
    case AppStatus.maintenanceOngoing:
      return [MaintenanceOngoingPage.page()];
    case AppStatus.updateRequired:
      return [UpdateRequiredPage.page()];
    case AppStatus.userPhoneVerificationRequired:
      print("OBJECT: PHONE AUTH PAGE");
      return [ExtraUserDetailsRequiredPage.page()];
  }
}

Upon state change, the print statements are being called, however there is no route change, any information is welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant