|
|
|
|
@ -192,42 +192,53 @@ class _MarkAttendanceWidgetState extends State<MarkAttendanceWidget> {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void getHuaweiCurrentLocation(String attendanceType) {
|
|
|
|
|
FusedLocationProviderClient locationService = FusedLocationProviderClient();
|
|
|
|
|
LocationRequest locationRequest = LocationRequest();
|
|
|
|
|
locationRequest.priority = LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY;
|
|
|
|
|
locationRequest.interval = 1000;
|
|
|
|
|
List<LocationRequest> locationRequestList = <LocationRequest>[locationRequest];
|
|
|
|
|
LocationSettingsRequest locationSettingsRequest = LocationSettingsRequest(requests: locationRequestList);
|
|
|
|
|
try {
|
|
|
|
|
FusedLocationProviderClient locationService = FusedLocationProviderClient();
|
|
|
|
|
LocationRequest locationRequest = LocationRequest();
|
|
|
|
|
locationRequest.priority = LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY;
|
|
|
|
|
locationRequest.interval = 1000;
|
|
|
|
|
List<LocationRequest> locationRequestList = <LocationRequest>[locationRequest];
|
|
|
|
|
LocationSettingsRequest locationSettingsRequest = LocationSettingsRequest(requests: locationRequestList);
|
|
|
|
|
|
|
|
|
|
locationService.checkLocationSettings(locationSettingsRequest).then((settings) async {
|
|
|
|
|
await locationService.getLastLocation().then((value) {
|
|
|
|
|
if (value.latitude == null || value.longitude == null) {
|
|
|
|
|
showDialog(
|
|
|
|
|
context: context,
|
|
|
|
|
builder: (BuildContext cxt) => ConfirmDialog(
|
|
|
|
|
message: "Unable to get your location, Please check your location settings & try again.",
|
|
|
|
|
onTap: () {
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
if (attendanceType == "QR") {
|
|
|
|
|
performQrCodeAttendance(widget.model, lat: value.latitude.toString() ?? "", lng: value.longitude.toString() ?? "");
|
|
|
|
|
}
|
|
|
|
|
if (attendanceType == "WIFI") {
|
|
|
|
|
performWifiAttendance(widget.model, lat: value.latitude.toString() ?? "", lng: value.longitude.toString() ?? "");
|
|
|
|
|
}
|
|
|
|
|
if (attendanceType == "NFC") {
|
|
|
|
|
performNfcAttendance(widget.model, lat: value.latitude.toString() ?? "", lng: value.longitude.toString() ?? "");
|
|
|
|
|
locationService.checkLocationSettings(locationSettingsRequest).then((settings) async {
|
|
|
|
|
await locationService.getLastLocation().then((value) {
|
|
|
|
|
if (value.latitude == null || value.longitude == null) {
|
|
|
|
|
showDialog(
|
|
|
|
|
context: context,
|
|
|
|
|
builder: (BuildContext cxt) => ConfirmDialog(
|
|
|
|
|
message: "Unable to get your location, Please check your location settings & try again.",
|
|
|
|
|
onTap: () {
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
if (attendanceType == "QR") {
|
|
|
|
|
performQrCodeAttendance(widget.model, lat: value.latitude.toString() ?? "", lng: value.longitude.toString() ?? "");
|
|
|
|
|
}
|
|
|
|
|
if (attendanceType == "WIFI") {
|
|
|
|
|
performWifiAttendance(widget.model, lat: value.latitude.toString() ?? "", lng: value.longitude.toString() ?? "");
|
|
|
|
|
}
|
|
|
|
|
if (attendanceType == "NFC") {
|
|
|
|
|
performNfcAttendance(widget.model, lat: value.latitude.toString() ?? "", lng: value.longitude.toString() ?? "");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}).catchError((error) {
|
|
|
|
|
print("HUAWEI LOCATION getLastLocation ERROR!!!!!");
|
|
|
|
|
print(error);
|
|
|
|
|
});
|
|
|
|
|
}).catchError((error) {
|
|
|
|
|
print("HUAWEI LOCATION checkLocationSettings ERROR!!!!!");
|
|
|
|
|
print(error);
|
|
|
|
|
if (error.code == "LOCATION_SETTINGS_NOT_AVAILABLE") {
|
|
|
|
|
// Location service not enabled.
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}).catchError((error) {
|
|
|
|
|
if (error.code == "LOCATION_SETTINGS_NOT_AVAILABLE") {
|
|
|
|
|
// Location service not enabled.
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
} catch(error) {
|
|
|
|
|
print("HUAWEI LOCATION ERROR!!!!!");
|
|
|
|
|
print(error);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> performNfcAttendance(DashboardProviderModel model, {String lat = "0", String lng = "0"}) async {
|
|
|
|
|
|