import 'package:flutter_custom_toolbox/flutter_toolbox.dart'; import 'package:reversi/common/config/activity_page.dart'; class NavCubitPage extends HydratedCubit<int> { NavCubitPage() : super(0); void updateIndex(int index) { if (ActivityPage.isIndexAllowed(index)) { emit(index); } else { emit(ActivityPage.indexHome); } } void goToPageHome() { updateIndex(ActivityPage.indexHome); } void goToPageGame() { updateIndex(ActivityPage.indexGame); } @override int fromJson(Map<String, dynamic> json) { return ActivityPage.indexHome; } @override Map<String, dynamic>? toJson(int state) { return <String, int>{'index': state}; } }