23 lines
698 B
Dart
23 lines
698 B
Dart
import 'package:bloc/bloc.dart';
|
|
import 'package:equatable/equatable.dart';
|
|
import 'package:location/location.dart';
|
|
import 'package:unit2/sevices/sos/sos_service.dart';
|
|
|
|
part 'sos_event.dart';
|
|
part 'sos_state.dart';
|
|
|
|
class SosBloc extends Bloc<SosEvent, SosState> {
|
|
SosBloc() : super(SosInitial()) {
|
|
LocationData? locationData;
|
|
on<LoadUserLocation>((event, emit)async {
|
|
emit(LoadingState());
|
|
|
|
LocationData? newLocationData =
|
|
await SosService.instance.getUserLocation();
|
|
locationData = newLocationData;
|
|
// User location Loaded and there is no mobile numbers in cache
|
|
emit(UserLocationLoaded(locationData: locationData!));
|
|
});
|
|
}
|
|
}
|