|  |  |  | @ -7,6 +7,7 @@ import 'package:geolocator/geolocator.dart'; | 
		
	
		
			
				|  |  |  |  | import 'package:huawei_location/location/fused_location_provider_client.dart'; | 
		
	
		
			
				|  |  |  |  | import 'package:huawei_location/location/location_request.dart'; | 
		
	
		
			
				|  |  |  |  | import 'package:huawei_location/location/location_settings_request.dart'; | 
		
	
		
			
				|  |  |  |  | import 'package:huawei_location/permission/permission_handler.dart'; | 
		
	
		
			
				|  |  |  |  | import 'package:mohem_flutter_app/api/dashboard_api_client.dart'; | 
		
	
		
			
				|  |  |  |  | import 'package:mohem_flutter_app/app_state/app_state.dart'; | 
		
	
		
			
				|  |  |  |  | import 'package:mohem_flutter_app/classes/colors.dart'; | 
		
	
	
		
			
				
					|  |  |  | @ -24,6 +25,7 @@ import 'package:mohem_flutter_app/widgets/location/Location.dart'; | 
		
	
		
			
				|  |  |  |  | import 'package:mohem_flutter_app/widgets/nfc/nfc_reader_sheet.dart'; | 
		
	
		
			
				|  |  |  |  | import 'package:mohem_flutter_app/widgets/qr_scanner_dialog.dart'; | 
		
	
		
			
				|  |  |  |  | import 'package:nfc_manager/nfc_manager.dart'; | 
		
	
		
			
				|  |  |  |  | import 'package:permission_handler/permission_handler.dart'; | 
		
	
		
			
				|  |  |  |  | import 'package:wifi_iot/wifi_iot.dart'; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | class MarkAttendanceWidget extends StatefulWidget { | 
		
	
	
		
			
				
					|  |  |  | @ -71,6 +73,36 @@ class _MarkAttendanceWidgetState extends State<MarkAttendanceWidget> { | 
		
	
		
			
				|  |  |  |  |     }); | 
		
	
		
			
				|  |  |  |  |   } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   void checkHuaweiLocationPermission(String attendanceType) async { | 
		
	
		
			
				|  |  |  |  |     PermissionHandler permissionHandler = PermissionHandler(); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     if (await permissionHandler.hasLocationPermission()) { | 
		
	
		
			
				|  |  |  |  |       getHuaweiCurrentLocation(attendanceType); | 
		
	
		
			
				|  |  |  |  |     } else { | 
		
	
		
			
				|  |  |  |  |       bool has = await requestPermissions(); | 
		
	
		
			
				|  |  |  |  |       if (has) { | 
		
	
		
			
				|  |  |  |  |         getHuaweiCurrentLocation(attendanceType); | 
		
	
		
			
				|  |  |  |  |       } else { | 
		
	
		
			
				|  |  |  |  |         showDialog( | 
		
	
		
			
				|  |  |  |  |           context: context, | 
		
	
		
			
				|  |  |  |  |           builder: (BuildContext cxt) => ConfirmDialog( | 
		
	
		
			
				|  |  |  |  |             message: "You need to give location permission to mark attendance", | 
		
	
		
			
				|  |  |  |  |             onTap: () { | 
		
	
		
			
				|  |  |  |  |               Navigator.pop(context); | 
		
	
		
			
				|  |  |  |  |             }, | 
		
	
		
			
				|  |  |  |  |           ), | 
		
	
		
			
				|  |  |  |  |         ); | 
		
	
		
			
				|  |  |  |  |       } | 
		
	
		
			
				|  |  |  |  |     } | 
		
	
		
			
				|  |  |  |  |   } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   Future<bool> requestPermissions() async { | 
		
	
		
			
				|  |  |  |  |     var result = await [ | 
		
	
		
			
				|  |  |  |  |       Permission.location, | 
		
	
		
			
				|  |  |  |  |     ].request(); | 
		
	
		
			
				|  |  |  |  |     return (result[Permission.location] == PermissionStatus.granted || result[Permission.locationAlways] == PermissionStatus.granted); | 
		
	
		
			
				|  |  |  |  |   } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   @override | 
		
	
		
			
				|  |  |  |  |   void dispose() { | 
		
	
		
			
				|  |  |  |  |     super.dispose(); | 
		
	
	
		
			
				
					|  |  |  | @ -101,7 +133,7 @@ class _MarkAttendanceWidgetState extends State<MarkAttendanceWidget> { | 
		
	
		
			
				|  |  |  |  |               attendanceMethod("NFC", "assets/images/nfc.svg", isNfcEnabled, () { | 
		
	
		
			
				|  |  |  |  |                 if (isNfcLocationEnabled) { | 
		
	
		
			
				|  |  |  |  |                   if (AppState().getIsHuawei) { | 
		
	
		
			
				|  |  |  |  |                     getHuaweiCurrentLocation("NFC"); | 
		
	
		
			
				|  |  |  |  |                     checkHuaweiLocationPermission("NFC"); | 
		
	
		
			
				|  |  |  |  |                   } else { | 
		
	
		
			
				|  |  |  |  |                     Location.getCurrentLocation((Position position, bool isMocked) { | 
		
	
		
			
				|  |  |  |  |                       if (isMocked) { | 
		
	
	
		
			
				
					|  |  |  | @ -119,7 +151,7 @@ class _MarkAttendanceWidgetState extends State<MarkAttendanceWidget> { | 
		
	
		
			
				|  |  |  |  |                 attendanceMethod("Wifi", "assets/images/wufu.svg", isWifiEnabled, () { | 
		
	
		
			
				|  |  |  |  |                   if (isWifiLocationEnabled) { | 
		
	
		
			
				|  |  |  |  |                     if (AppState().getIsHuawei) { | 
		
	
		
			
				|  |  |  |  |                       getHuaweiCurrentLocation("WIFI"); | 
		
	
		
			
				|  |  |  |  |                       checkHuaweiLocationPermission("WIFI"); | 
		
	
		
			
				|  |  |  |  |                     } else { | 
		
	
		
			
				|  |  |  |  |                       Location.getCurrentLocation((Position position, bool isMocked) { | 
		
	
		
			
				|  |  |  |  |                         if (isMocked) { | 
		
	
	
		
			
				
					|  |  |  | @ -138,7 +170,7 @@ class _MarkAttendanceWidgetState extends State<MarkAttendanceWidget> { | 
		
	
		
			
				|  |  |  |  |                 attendanceMethod("QR", "assets/images/ic_qr.svg", isQrEnabled, () async { | 
		
	
		
			
				|  |  |  |  |                   if (isQrLocationEnabled) { | 
		
	
		
			
				|  |  |  |  |                     if (AppState().getIsHuawei) { | 
		
	
		
			
				|  |  |  |  |                       getHuaweiCurrentLocation("QR"); | 
		
	
		
			
				|  |  |  |  |                       checkHuaweiLocationPermission("QR"); | 
		
	
		
			
				|  |  |  |  |                     } else { | 
		
	
		
			
				|  |  |  |  |                       Location.getCurrentLocation((Position position, bool isMocked) { | 
		
	
		
			
				|  |  |  |  |                         if (isMocked) { | 
		
	
	
		
			
				
					|  |  |  | @ -170,14 +202,26 @@ class _MarkAttendanceWidgetState extends State<MarkAttendanceWidget> { | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     locationService.checkLocationSettings(locationSettingsRequest).then((settings) async { | 
		
	
		
			
				|  |  |  |  |       await locationService.getLastLocation().then((value) { | 
		
	
		
			
				|  |  |  |  |         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() ?? ""); | 
		
	
		
			
				|  |  |  |  |         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) { | 
		
	
	
		
			
				
					|  |  |  | 
 |