A Flutter demo for flutter_bloc(Cubit) + Nested Navigation
BlocBuilder<AuthBloc, AuthState>(
builder: (context, state) {
return state.when(
authorized: (user) => AuthorizedNavigation(),
unauthorized: () => AuthorizationNavigation(),
);
},
buildWhen: (previous, current) {
return previous.runtimeType != current.runtimeType;
},
);
class AccountAppBar extends StatelessWidget implements PreferredSizeWidget {
@override
Widget build(BuildContext context) {
return BlocBuilder<AuthBloc, AuthState>(
builder: (context, state){
return state.when(
authorized: (data) {
return Material(
...
);
},
unauthorized: () => SizedBox(),
);
},
);
}
@override
Size get preferredSize => Size.fromHeight(kToolbarHeight);
}