felangel / felangel/flow_builder

Generated Route Access With Flow Builder

Open
#101 0 comments 5 reactions 0 assignees View on GitHub
Dominant language
Dart
Stars
416
Forks
68
PR merge metrics
No merged PRs in 30d

Description

I'm new to this package, I have nested routes with **Authentication** and many many blocs and i use **Generated Route Access**

**Generated Route**
```
class AppRouter {
AppRouter();
static final loginBloc = LoginCubit(
authBloc: authBloc,
);
static final authBloc = AuthBloc();
static const String home = '/';
static const String login = 'login';
static const String profile = '/profile';
Route onGenerateRoute(RouteSettings settings) {
switch (settings.name) {
/// Auth
case home:
case login:
return MaterialPageRoute(
builder: (_) => MultiBlocProvider(
providers: [
BlocProvider.value(
value: authBloc,
),
BlocProvider.value(
value: loginBloc,
),
],
child: const AuthFlow(),
),
);

/// Profile
case profile:
return MaterialPageRoute(
builder: (_) => MultiBlocProvider(
providers: [
BlocProvider.value(
value: authBloc,
),
],
child: const ProfilePage(),
),
);
}

```
i use **Flow Builder in Authentication**
```
class AuthFlow extends StatelessWidget {
const AuthFlow({super.key});
@override
Widget build(BuildContext context) {
return FlowBuilder(
state: context.select((AuthBloc state) => state.state),
onGeneratePages: (projectState, pages) {
if (projectState.status == AuthenticationStatus.authenticated) {
context.read().add(const GetListProject());
context.read().add(const GetList());
}
return [
if (projectState.status == AuthenticationStatus.authenticated)
const MaterialPage(child: HomePage())
else
const MaterialPage(child: LoginPage()),
];
},
);
}
}

```
But inside the **HomePage** when i go to the profile this error appears

**Navigation Code**
` Navigator.of(context).pushNamed(AppRouter.profile);`

**Error Code**
`Navigator.onGenerateRoute was null, but the route named "/profile" was referenced. To use the Navigator API with named routes (pushNamed, pushReplacementNamed, or pushNamedAndRemoveUntil), the Navigator must be provided with an onGenerateRoute handler. `

**Is there another way to use the library with Generated Route?**

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.