getGpsAccess method

Future<void> getGpsAccess()

Implementation

Future<void> getGpsAccess() async {
  final status = await Permission.location.request();

  switch (status) {
    case PermissionStatus.granted:
      add(GpsAndPermissionEvent(
          isGpsEnable: state.isGpsEnabled, isGpsPermissionGranted: true));
    case PermissionStatus.denied:
    case PermissionStatus.restricted:
    case PermissionStatus.limited:
    case PermissionStatus.permanentlyDenied:
      add(GpsAndPermissionEvent(
          isGpsEnable: state.isGpsEnabled, isGpsPermissionGranted: false));
      openAppSettings();
    case PermissionStatus.provisional:
      add(GpsAndPermissionEvent(
          isGpsEnable: state.isGpsEnabled, isGpsPermissionGranted: true));
  }
}