Project 'android/wordguessing' was moved to 'android/org.benoitharrault.wordguessing'. Please update any links and bookmarks that may still have the old path.
Select Git revision
nav_cubit.dart
nav_cubit.dart 677 B
import 'package:hydrated_bloc/hydrated_bloc.dart';
import 'package:wordguessing/config/menu.dart';
class NavCubit extends HydratedCubit<int> {
NavCubit() : super(0);
void updateIndex(int index) {
if (Menu.isIndexAllowed(index)) {
emit(index);
} else {
goToGamePage();
}
}
void goToGamePage() {
emit(Menu.indexGame);
}
void goToSettingsPage() {
emit(Menu.indexSettings);
}
void goToAboutPage() {
emit(Menu.indexAbout);
}
@override
int fromJson(Map<String, dynamic> json) {
return Menu.indexGame;
}
@override
Map<String, dynamic>? toJson(int state) {
return <String, int>{'pageIndex': state};
}
}