felangel / felangel/flow_builder
Generated Route Access With Flow Builder
- Lingua principale
- Dart
- Stelle
- 416
- Fork
- 68
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
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?**
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Valutazione
Questa issue non è ancora stata valutata.