import 'package:flutter_custom_toolbox/flutter_toolbox.dart'; import 'package:puissance4/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}; } }