Skip to content

Instantly share code, notes, and snippets.

@techpotatoes
Created June 2, 2020 13:14
Show Gist options
  • Save techpotatoes/a55decdea839b13145b61b73ea61a375 to your computer and use it in GitHub Desktop.
Save techpotatoes/a55decdea839b13145b61b73ea61a375 to your computer and use it in GitHub Desktop.
Flutter development series – Part 5
class NavigatorBloc extends Bloc<NavigatorEvent, dynamic>{
final GlobalKey<NavigatorState> navigatorKey;
NavigatorBloc({this.navigatorKey});
@override
dynamic get initialState => "Initial";
@override
Stream<dynamic> mapEventToState(NavigatorEvent event) async* {
if(event is NavigatorEventPop){
navigatorKey.currentState.pop();
}else if(event is NavigatorEventAdd){
navigatorKey.currentState.pushNamed('/add');
}
yield "Updated";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment