You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			524 lines
		
	
	
		
			18 KiB
		
	
	
	
		
			Dart
		
	
			
		
		
	
	
			524 lines
		
	
	
		
			18 KiB
		
	
	
	
		
			Dart
		
	
| import 'dart:async';
 | |
| import 'dart:convert';
 | |
| import 'dart:io';
 | |
| 
 | |
| import 'package:easy_localization/easy_localization.dart';
 | |
| import 'package:easy_localization/src/public_ext.dart';
 | |
| import 'package:firebase_core/firebase_core.dart';
 | |
| import 'package:firebase_crashlytics/firebase_crashlytics.dart';
 | |
| import 'package:firebase_messaging/firebase_messaging.dart';
 | |
| import 'package:flutter/foundation.dart';
 | |
| import 'package:flutter/material.dart';
 | |
| import 'package:flutter/services.dart';
 | |
| import 'package:flutter_callkit_incoming/entities/call_event.dart';
 | |
| import 'package:flutter_callkit_incoming/flutter_callkit_incoming.dart';
 | |
| import 'package:flutter_ios_voip_kit/call_state_type.dart';
 | |
| import 'package:flutter_ios_voip_kit/flutter_ios_voip_kit.dart';
 | |
| import 'package:logger/logger.dart';
 | |
| import 'package:mohem_flutter_app/api/chat/chat_api_client.dart';
 | |
| 
 | |
| // import 'package:huawei_hmsavailability/huawei_hmsavailability.dart';
 | |
| import 'package:mohem_flutter_app/api/login_api_client.dart';
 | |
| import 'package:mohem_flutter_app/app_state/app_state.dart';
 | |
| import 'package:mohem_flutter_app/classes/chat_call_kit.dart';
 | |
| import 'package:mohem_flutter_app/classes/colors.dart';
 | |
| import 'package:mohem_flutter_app/classes/consts.dart';
 | |
| import 'package:mohem_flutter_app/classes/notifications.dart';
 | |
| import 'package:mohem_flutter_app/classes/utils.dart';
 | |
| import 'package:mohem_flutter_app/config/routes.dart';
 | |
| import 'package:mohem_flutter_app/extensions/int_extensions.dart';
 | |
| import 'package:mohem_flutter_app/extensions/string_extensions.dart';
 | |
| import 'package:mohem_flutter_app/extensions/widget_extensions.dart';
 | |
| import 'package:mohem_flutter_app/generated/locale_keys.g.dart';
 | |
| import 'package:mohem_flutter_app/main.dart';
 | |
| import 'package:mohem_flutter_app/models/chat/call.dart';
 | |
| import 'package:mohem_flutter_app/models/chat/get_user_login_token_model.dart';
 | |
| import 'package:mohem_flutter_app/models/check_mobile_app_version_model.dart';
 | |
| import 'package:mohem_flutter_app/models/get_mobile_login_info_list_model.dart';
 | |
| import 'package:mohem_flutter_app/models/member_information_list_model.dart';
 | |
| import 'package:mohem_flutter_app/models/member_login_list_model.dart';
 | |
| import 'package:mohem_flutter_app/models/privilege_list_model.dart';
 | |
| import 'package:mohem_flutter_app/ui/chat/call/chat_incoming_call_screen.dart';
 | |
| import 'package:mohem_flutter_app/widgets/button/default_button.dart';
 | |
| import 'package:mohem_flutter_app/widgets/button/hmg_connectivity_button.dart';
 | |
| import 'package:mohem_flutter_app/widgets/input_widget.dart';
 | |
| 
 | |
| // import 'package:safe_device/safe_device.dart';
 | |
| import 'package:wifi_iot/wifi_iot.dart';
 | |
| 
 | |
| class LoginScreen extends StatefulWidget {
 | |
|   LoginScreen({Key? key}) : super(key: key);
 | |
| 
 | |
|   @override
 | |
|   _LoginScreenState createState() {
 | |
|     return _LoginScreenState();
 | |
|   }
 | |
| }
 | |
| 
 | |
| class _LoginScreenState extends State<LoginScreen> with WidgetsBindingObserver{
 | |
|   TextEditingController username = TextEditingController();
 | |
|   TextEditingController password = TextEditingController();
 | |
| 
 | |
|   CheckMobileAppVersionModel? _checkMobileAppVersion;
 | |
|   MemberLoginListModel? _memberLoginList;
 | |
| 
 | |
|   late final FirebaseMessaging _firebaseMessaging;
 | |
|   IosCallPayload? _iosCallPayload;
 | |
| 
 | |
| 
 | |
|   bool _autoLogin = false;
 | |
| 
 | |
|   bool? isAppOpenBySystem;
 | |
| 
 | |
|   bool isJailBroken = false;
 | |
|   bool isRealDevice = false;
 | |
|   bool isOnExternalStorage = false;
 | |
|   bool isDevelopmentModeEnable = false;
 | |
|   bool isIncomingCall = false;
 | |
| 
 | |
|   // late HmsApiAvailability hmsApiAvailability;
 | |
| 
 | |
|   final voIPKit = FlutterIOSVoIPKit.instance;
 | |
|   late Timer timeOutTimer;
 | |
|   
 | |
|   
 | |
|   @override
 | |
|   void initState() {
 | |
|     super.initState();
 | |
|     // hmsApiAvailability = HmsApiAvailability();
 | |
|     // checkFirebaseToken();
 | |
|     // if (kReleaseMode) {
 | |
|     //   checkDeviceSafety();
 | |
|     // }
 | |
|     WidgetsBinding.instance.addObserver(this);
 | |
|     if (Platform.isAndroid) {
 | |
|       callListeners();
 | |
|       checkAndNavigationCallingPage();
 | |
|     }
 | |
|     setupVoIPCallBacks();
 | |
|   }
 | |
| 
 | |
|   void _timeOut({
 | |
|     int seconds = 15,
 | |
|   }) async {
 | |
|     timeOutTimer = Timer(Duration(seconds: seconds), () async {
 | |
|       print('🎈 example: timeOut');
 | |
|       var incomingCallerName = await voIPKit.getIncomingCallerName();
 | |
|       voIPKit.unansweredIncomingCall(
 | |
|         skipLocalNotification: false,
 | |
|         missedCallTitle: '📞 Missed call',
 | |
|         missedCallBody: 'There was a call from $incomingCallerName',
 | |
|       );
 | |
|     });
 | |
|   }
 | |
| 
 | |
|   void setupVoIPCallBacks() {
 | |
|     if (Platform.isIOS) {
 | |
|       voIPKit.getVoIPToken().then((value) {
 | |
|         print('🎈 example: getVoIPToken: $value');
 | |
|       });
 | |
| 
 | |
|       voIPKit.onDidUpdatePushToken = (String token) {
 | |
|         print('🎈 example: onDidUpdatePushToken: $token');
 | |
|       };
 | |
|     }
 | |
| 
 | |
|     voIPKit.onDidReceiveIncomingPush = (
 | |
|         Map<String, dynamic> payload,
 | |
|         ) async {
 | |
|       _iosCallPayload = IosCallPayload.fromJson(payload);
 | |
|       logger.d(_iosCallPayload!.incomingCallerId!.split("-").last);
 | |
|       print('🎈 example: onDidReceiveIncomingPush $payload');
 | |
|       _timeOut();
 | |
|     };
 | |
| 
 | |
|     voIPKit.onDidRejectIncomingCall = (
 | |
|         String uuid,
 | |
|         String callerId,
 | |
|         ) async {
 | |
|       try {
 | |
|         var logText = "did reject call $callerId";
 | |
|       } catch (err) {}
 | |
|     };
 | |
| 
 | |
|     voIPKit.onDidAcceptIncomingCall = (
 | |
|         String uuid,
 | |
|         String callerId,
 | |
|         ) async {
 | |
|       var callerID = "did accept call $callerId";
 | |
| 
 | |
|       debugPrint(callerID);
 | |
|       logger.d(_iosCallPayload!.incomingCallerId!.split("-").last);
 | |
|       debugPrint(_iosCallPayload!.incomingCallerId);
 | |
|       debugPrint(_iosCallPayload!.incomingCallerName);
 | |
|       debugPrint(_iosCallPayload!.incomingCallType);
 | |
|       await connectCall();
 | |
|       await voIPKit.acceptIncomingCall(callerState: CallStateType.calling);
 | |
|       await voIPKit.callConnected();
 | |
| 
 | |
|       Future.delayed(const Duration(milliseconds: 2500), () {
 | |
|         voIPKit.endCall().then((value) async {});
 | |
|       });
 | |
| 
 | |
|       timeOutTimer.cancel();
 | |
|     };
 | |
|   }
 | |
| 
 | |
| 
 | |
|   Future<void> connectCall() async {
 | |
|     
 | |
|     try {
 | |
|       UserAutoLoginModel userLoginResponse = await ChatApiClient().getUserCallToken(userid: _iosCallPayload!.incomingCallerId!.split("-").last);
 | |
|       if (userLoginResponse.response != null) {
 | |
|         AppState().setchatUserDetails = userLoginResponse;
 | |
|         Utils.saveStringFromPrefs("userLoginChatDetails", jsonEncode(userLoginResponse.response));
 | |
|       }
 | |
|     } catch (e) {
 | |
|       logger.d(e);
 | |
|     }
 | |
|   }
 | |
| 
 | |
|   // void checkDeviceSafety() async {
 | |
|   //   try {
 | |
|   //     isJailBroken = await SafeDevice.isJailBroken;
 | |
|   //     isRealDevice = await SafeDevice.isRealDevice;
 | |
|   //     if (Platform.isAndroid) {
 | |
|   //       isOnExternalStorage = await SafeDevice.isOnExternalStorage;
 | |
|   //       isDevelopmentModeEnable = await SafeDevice.isDevelopmentModeEnable;
 | |
|   //     }
 | |
|   //     if (isJailBroken || !isRealDevice || isOnExternalStorage || isDevelopmentModeEnable) {
 | |
|   //       Navigator.pushNamedAndRemoveUntil(context, AppRoutes.unsafeDeviceScreen, (_) => false);
 | |
|   //     }
 | |
|   //   } catch (error) {
 | |
|   //     print(error);
 | |
|   //   }
 | |
|   // }
 | |
|   // Future<void> connectCall() async {
 | |
|   //   try {
 | |
|   //     UserAutoLoginModel userLoginResponse = await ChatApiClient().getUserCallToken(userid: _iosCallPayload!.incomingCallerId!.split("-").last);
 | |
|   //     if (userLoginResponse.response != null) {
 | |
|   //       AppState().setchatUserDetails = userLoginResponse;
 | |
|   //       Utils.saveStringFromPrefs("userLoginChatDetails", jsonEncode(userLoginResponse.response));
 | |
|   //     }
 | |
|   //   } catch (e) {
 | |
|   //     logger.d(e);
 | |
|   //   }
 | |
|   // }
 | |
| 
 | |
| 
 | |
|   Future<void> callListeners() async {
 | |
|     try {
 | |
|       print("Call Listeners Init");
 | |
|       FlutterCallkitIncoming.onEvent.listen((CallEvent? event) async {
 | |
|         switch (event!.event) {
 | |
|           
 | |
|           case Event.actionCallIncoming:
 | |
|             break;
 | |
|           case Event.actionCallStart:
 | |
|             break;
 | |
|           case Event.actionCallAccept:
 | |
|             if (mounted) {
 | |
|               isIncomingCall = true;
 | |
|               moveToCallScreen();
 | |
|             }
 | |
|             break;
 | |
|           case Event.actionCallDecline:
 | |
|             Utils.saveStringFromPrefs("isIncomingCall", "false");
 | |
|             Utils.saveStringFromPrefs("inComingCallData", "null");
 | |
|             FlutterCallkitIncoming.endAllCalls();
 | |
| 
 | |
|             break;
 | |
|           case Event.actionCallEnded:
 | |
|             Utils.saveStringFromPrefs("isIncomingCall", "false");
 | |
|             Utils.saveStringFromPrefs("inComingCallData", "null");
 | |
|             FlutterCallkitIncoming.endAllCalls();
 | |
|             break;
 | |
|           case Event.actionCallTimeout:
 | |
|             Utils.saveStringFromPrefs("isIncomingCall", "false");
 | |
|             Utils.saveStringFromPrefs("inComingCallData", "null");
 | |
|             FlutterCallkitIncoming.endAllCalls();
 | |
|             break;
 | |
| 
 | |
|         }
 | |
|         print( '${event.toString()}\n');
 | |
| 
 | |
|       });
 | |
|     } on Exception {
 | |
|       logger.log(Level.info, "EXCEPTION-ON-EVENTS");
 | |
|     }
 | |
|   }
 | |
| 
 | |
|   Future<void> moveToCallScreen() async {
 | |
|     dynamic calls = await FlutterCallkitIncoming.activeCalls();
 | |
|     if (calls is List) {
 | |
|       if (calls.isNotEmpty) {
 | |
|         if (Platform.isAndroid) {
 | |
|           Utils.hideLoading(context);
 | |
|         }
 | |
|         var pageRoute = MaterialPageRoute(builder: (context) => StartCallPage());
 | |
|         Navigator.push(context, pageRoute).whenComplete(() {
 | |
|           checkFirebaseToken();
 | |
|         });
 | |
|       } else {
 | |
|         FlutterCallkitIncoming.endAllCalls();
 | |
|         Utils.showToast("Something wen't wrong");
 | |
|       }
 | |
|     }
 | |
|   }
 | |
| 
 | |
|   Future<dynamic> getCurrentCall() async {
 | |
|     //check current call from pushkit if possible
 | |
|     var calls = await FlutterCallkitIncoming.activeCalls();
 | |
|     if (calls is List) {
 | |
|       if (calls.isNotEmpty) {
 | |
|         print('DATA: $calls');
 | |
|         return calls[0];
 | |
|       } else {
 | |
|         return null;
 | |
|       }
 | |
|     }
 | |
|   }
 | |
| 
 | |
|   Future<void> checkAndNavigationCallingPage() async {
 | |
|     var currentCall = await getCurrentCall();
 | |
|     if (currentCall != null && Platform.isAndroid) {
 | |
|       isIncomingCall = true;
 | |
|       Utils.hideLoading(context);
 | |
|       Navigator.push(context, MaterialPageRoute(builder: (context) => StartCallPage()));
 | |
|     }
 | |
|   }
 | |
| 
 | |
| 
 | |
|   
 | |
| 
 | |
|   @override
 | |
|   void dispose() {
 | |
|     super.dispose();
 | |
|   }
 | |
| 
 | |
|   String? firebaseToken;
 | |
|   GetMobileLoginInfoListModel? loginInfo;
 | |
| 
 | |
|   Future<void> checkFirebaseToken() async {
 | |
|     try {
 | |
|       Utils.showLoading(context);
 | |
|       if (Platform.isAndroid) {
 | |
|         try {
 | |
|           if (!(await Utils.isGoogleServicesAvailable())) {
 | |
|             print("HUAWEI APPPP GALLERYYYY!!!!");
 | |
|             AppState().setIsHuawei = true;
 | |
|             AppNotifications().initHuaweiPush(checkLoginInfo);
 | |
|           } else {
 | |
|             print("GOOGLE PLAY STOREEEE!!!!");
 | |
|             await Firebase.initializeApp();
 | |
|             _firebaseMessaging = FirebaseMessaging.instance;
 | |
|             firebaseToken = await _firebaseMessaging.getToken();
 | |
|             AppNotifications().init(firebaseToken);
 | |
|             checkLoginInfo();
 | |
|             await FirebaseCrashlytics.instance.setCrashlyticsCollectionEnabled(true);
 | |
|           }
 | |
|           // });
 | |
|         } catch (ex) {}
 | |
|       } else {
 | |
|         await Firebase.initializeApp();
 | |
|         _firebaseMessaging = FirebaseMessaging.instance;
 | |
|         firebaseToken = await _firebaseMessaging.getToken();
 | |
|         AppNotifications().init(firebaseToken);
 | |
|         checkLoginInfo();
 | |
|         await FirebaseCrashlytics.instance.setCrashlyticsCollectionEnabled(true);
 | |
|       }
 | |
|     } catch (ex) {
 | |
|       Utils.hideLoading(context);
 | |
|       Utils.handleException(ex, context, null);
 | |
|       await FirebaseCrashlytics.instance.setCrashlyticsCollectionEnabled(true);
 | |
|     }
 | |
|   }
 | |
| 
 | |
|   void checkLoginInfo() async {
 | |
|     loginInfo = await LoginApiClient().getMobileLoginInfoNEW(AppState().getIsHuawei ? AppState().getHuaweiPushToken : firebaseToken ?? "", Platform.isAndroid ? "android" : "ios");
 | |
|     if (loginInfo == null) {
 | |
|       await checkPrefs();
 | |
|       _autoLogin = false;
 | |
|       Utils.hideLoading(context);
 | |
|       return;
 | |
|     } else {
 | |
|       loginInfo!.deviceToken = firebaseToken;
 | |
|       await checkPrefs();
 | |
|       Utils.hideLoading(context);
 | |
|       performLogin();
 | |
|     }
 | |
|   }
 | |
| 
 | |
|   Future<void> checkPrefs() async {
 | |
|     String username = await Utils.getStringFromPrefs(SharedPrefsConsts.username);
 | |
|     if (username.isNotEmpty) {
 | |
|       String password = await Utils.getStringFromPrefs(SharedPrefsConsts.password);
 | |
|       // String firebaseToken = await Utils.getStringFromPrefs(SharedPrefsConsts.firebaseToken);
 | |
|       // print("firebaseToken:$firebaseToken");
 | |
|       this.username.text = username;
 | |
|       this.password.text = password;
 | |
|       _autoLogin = true;
 | |
|     }
 | |
|   }
 | |
| 
 | |
|   void performLogin() async {
 | |
|     Utils.showLoading(context);
 | |
|     try {
 | |
|       _checkMobileAppVersion = await LoginApiClient().checkMobileAppVersion();
 | |
|       _memberLoginList = await LoginApiClient().memberLogin(username.text, password.text);
 | |
|       AppState().setMemberLoginListModel = _memberLoginList;
 | |
|       AppState().setUserName = username.text;
 | |
|       AppState().password = password.text;
 | |
|       if (_autoLogin) {
 | |
|         AppState().setMemberInformationListModel = (await MemberInformationListModel.getFromPrefs()).first;
 | |
|         AppState().setPrivilegeListModel = await PrivilegeListModel.getFromPrefs();
 | |
|         String mohemmWifiSSID = await Utils.getStringFromPrefs(SharedPrefsConsts.mohemmWifiSSID);
 | |
|         String mohemmWifiPassword = await Utils.getStringFromPrefs(SharedPrefsConsts.mohemmWifiPassword);
 | |
|         AppState().setMohemmWifiSSID = mohemmWifiSSID;
 | |
|         AppState().setMohemmWifiPassword = mohemmWifiPassword;
 | |
|       }
 | |
|       Utils.hideLoading(context);
 | |
|       if (_autoLogin) {
 | |
|         Navigator.pushReplacementNamed(context, AppRoutes.verifyLastLogin, arguments: loginInfo);
 | |
|       } else {
 | |
|         Navigator.pushNamed(context, AppRoutes.verifyLogin, arguments: "$firebaseToken");
 | |
|       }
 | |
|       Utils.saveStringFromPrefs(SharedPrefsConsts.password, password.text);
 | |
|     } catch (ex) {
 | |
|       Utils.hideLoading(context);
 | |
|       Utils.handleException(ex, context, (msg) {
 | |
|         Utils.confirmDialog(context, msg);
 | |
|       });
 | |
|     }
 | |
|   }
 | |
| 
 | |
|   @override
 | |
|   Widget build(BuildContext context) {
 | |
|     if (isAppOpenBySystem == null) {
 | |
|       isAppOpenBySystem = (ModalRoute.of(context)!.settings.arguments ?? true) as bool;
 | |
|       if (!kReleaseMode) {
 | |
|         // username.text = "15444"; // Maha User
 | |
|         // username.text = "15153"; // Tamer User
 | |
|         // password.text = "Abcd@12345";
 | |
| 
 | |
|         // username.text = "206535"; // Hashim User
 | |
|         // password.text = "Namira786";
 | |
| 
 | |
|         // 13777
 | |
|         // Ab12345cd
 | |
|       }
 | |
|      // if (isAppOpenBySystem!) checkFirebaseToken();
 | |
| 
 | |
|       Utils.showLoading(context);
 | |
|       Future.delayed(const Duration(seconds: 2)).whenComplete(() {
 | |
|         if (!isIncomingCall) {
 | |
|           if (isAppOpenBySystem!) checkFirebaseToken();
 | |
|         }
 | |
|       });
 | |
|     }
 | |
| 
 | |
|     // username.text = "15444";
 | |
| 
 | |
|     return Scaffold(
 | |
|       body: Column(
 | |
|         children: [
 | |
|           const SizedBox(height: 23),
 | |
|           Expanded(
 | |
|             child: Padding(
 | |
|               padding: const EdgeInsets.all(21.0),
 | |
|               child: Column(
 | |
|                 crossAxisAlignment: CrossAxisAlignment.start,
 | |
|                 children: [
 | |
|                   Row(
 | |
|                     children: [
 | |
|                       // Expanded(
 | |
|                       //   child:SizedBox(child: HmgConnectivityButton(),),
 | |
|                       // ),
 | |
|                       Row(
 | |
|                         children: [
 | |
|                           LocaleKeys.english.tr().toText14(color: AppState().isArabic(context) ? null : MyColors.textMixColor).onPress(() {
 | |
|                             context.setLocale(const Locale("en", "US"));
 | |
|                           }),
 | |
|                           Container(
 | |
|                             width: 1,
 | |
|                             color: MyColors.darkWhiteColor,
 | |
|                             height: 16,
 | |
|                             margin: const EdgeInsets.only(left: 10, right: 10),
 | |
|                           ),
 | |
|                           LocaleKeys.arabic.tr().toText14(color: !AppState().isArabic(context) ? null : MyColors.textMixColor).onPress(() {
 | |
|                             context.setLocale(const Locale("ar", "SA"));
 | |
|                           }),
 | |
|                         ],
 | |
|                       ),
 | |
|                     ],
 | |
|                   ),
 | |
|                   Expanded(
 | |
|                     child: Column(
 | |
|                       mainAxisSize: MainAxisSize.min,
 | |
|                       crossAxisAlignment: CrossAxisAlignment.start,
 | |
|                       mainAxisAlignment: MainAxisAlignment.center,
 | |
|                       children: [
 | |
|                         LocaleKeys.login.tr().toText24(isBold: true),
 | |
|                         LocaleKeys.pleaseEnterLoginDetails.tr().toText16(),
 | |
|                         16.height,
 | |
|                         InputWidget(LocaleKeys.username.tr(), "123456", username),
 | |
|                         12.height,
 | |
|                         InputWidget(LocaleKeys.password.tr(), "xxxxxx", password, isTextIsPassword: true),
 | |
|                         9.height,
 | |
|                         Align(
 | |
|                           alignment: Alignment.centerRight,
 | |
|                           child: LocaleKeys.forgotPassword.tr().toText12(isUnderLine: true, color: MyColors.textMixColor).onPress(() {
 | |
|                             Navigator.pushNamed(context, AppRoutes.forgotPassword);
 | |
|                           }),
 | |
|                         ),
 | |
|                         20.height,
 | |
|                         // DefaultButton(
 | |
|                         //   "Connect HMG Network",
 | |
|                         //   () async {
 | |
|                         //     SystemChannels.textInput.invokeMethod('TextInput.hide');
 | |
|                         //     connectWithHmgNetwork();
 | |
|                         //   },
 | |
|                         // ),
 | |
|                       ],
 | |
|                     ),
 | |
|                   )
 | |
|                 ],
 | |
|               ),
 | |
|             ),
 | |
|           ),
 | |
|           DefaultButton(LocaleKeys.login.tr(), () async {
 | |
|             SystemChannels.textInput.invokeMethod('TextInput.hide');
 | |
|             performLogin();
 | |
|           }).insideContainer
 | |
|         ],
 | |
|       ),
 | |
|     );
 | |
|   }
 | |
| 
 | |
|   void connectWithHmgNetwork() async {
 | |
|     try {
 | |
|       bool isConnected = await WiFiForIoTPlugin.connect("MOHEMM-CONNECT", password: "0987654321", joinOnce: Platform.isIOS ? false : true, security: NetworkSecurity.WPA, withInternet: false);
 | |
| 
 | |
|       if (isConnected) {
 | |
|         await WiFiForIoTPlugin.forceWifiUsage(true);
 | |
|         // if (Platform.isIOS) {
 | |
|         //   await closeWifiRequest();
 | |
|         //   await Future.delayed(Duration(seconds: 6));
 | |
|         // } else {
 | |
|         //   await WiFiForIoTPlugin.forceWifiUsage(true);
 | |
|         // }
 | |
|       }
 | |
|     } catch (e) {
 | |
|       print("----------------o----");
 | |
|       print(e);
 | |
|     }
 | |
|   }
 | |
| 
 | |
|   Future<bool> closeWifiRequest() async {
 | |
|     if (Platform.isAndroid) {
 | |
|       await WiFiForIoTPlugin.forceWifiUsage(false);
 | |
|     }
 | |
|     return await WiFiForIoTPlugin.disconnect();
 | |
|   }
 | |
| }
 |