import 'package:flutter_bloc/flutter_bloc.dart'; class AppState { final bool online; final String? role; final String? serverUrl; final String localeCode; const AppState({ required this.online, this.role, this.serverUrl, this.localeCode = 'id-ID', }); AppState copyWith({ bool? online, String? role, String? serverUrl, String? localeCode, }) { return AppState( online: online ?? this.online, role: role ?? this.role, serverUrl: serverUrl ?? this.serverUrl, localeCode: localeCode ?? this.localeCode, ); } } class AppCubit extends Cubit { AppCubit() : super(const AppState(online: true)); void setSession({required String role, required String serverUrl}) { emit(state.copyWith(role: role, serverUrl: serverUrl, online: true)); } void setOnline(bool value) => emit(state.copyWith(online: value)); void setLocaleCode(String value) => emit(state.copyWith(localeCode: value)); void clearSession() => emit(const AppState(online: true)); }