passo_mobile_app/lib/bloc/offline/offline_bloc/offline_bloc.dart

29 lines
929 B
Dart
Raw Normal View History

2023-10-06 12:19:06 +00:00
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:unit2/utils/global.dart';
import '../../../model/offline/offlane_modules.dart';
import '../../../model/offline/offline_profile.dart';
part 'offline_event.dart';
part 'offline_state.dart';
class OfflineBloc extends Bloc<OfflineEvent, OfflineState> {
OfflineBloc() : super(OfflineInitial()) {
on<SwitchOffline>((event, emit) async {
try {
List<dynamic> modules = await OFFLINE!.get('modules');
List<OfflineModules> offlineModules = [];
for (var module in modules) {
offlineModules.add(module);
}
OfflineProfile offlineProfile = await OFFLINE!.get('offline_profile');
emit(OfflineModeState(
offlineModules: offlineModules, offlineProfile: offlineProfile));
} catch (e) {
emit(OfflineErrorState(message: e.toString()));
}
});
}
}