diff --git a/lib/routes.dart b/lib/routes.dart index 7df15030..7e0bd7ee 100644 --- a/lib/routes.dart +++ b/lib/routes.dart @@ -79,7 +79,7 @@ var routes = { PACKAGES_ORDER_COMPLETED: (_) => PackageOrderCompletedPage(), TEST_PAGE: (_) => TestPage(), HEALTH_WEATHER: (_) => HealthWeatherIndicator(), - APP_UPDATE: (_) => AppUpdatePage(), + APP_UPDATE: (_) => AppUpdatePage(appUpdateText: '',), SETTINGS: (_) => Settings(), CART_ORDER_PAGE: (_) => CartOrderPage(), // CALL_PAGE: (_) => CallPage(), diff --git a/lib/uitl/CalendarUtils.dart b/lib/uitl/CalendarUtils.dart index 4cf55a86..8f549d48 100644 --- a/lib/uitl/CalendarUtils.dart +++ b/lib/uitl/CalendarUtils.dart @@ -7,9 +7,9 @@ import 'package:timezone/timezone.dart'; final DeviceCalendarPlugin deviceCalendarPlugin = DeviceCalendarPlugin(); class CalendarUtils { - static Completer _completer; + static Completer? _completer; - Calendar get writableCalendars => calendars?.firstWhere((c) => !c.isReadOnly); + Calendar? get writableCalendars => calendars?.firstWhere((c) => !c.isReadOnly!); List calendars; CalendarUtils._(this.calendars); @@ -19,15 +19,15 @@ class CalendarUtils { _completer = Completer(); try { final calendarsResult = await deviceCalendarPlugin.retrieveCalendars(); - _completer.complete(CalendarUtils._(calendarsResult?.data)); + _completer?.complete(CalendarUtils._(calendarsResult?.data!)); } on Exception catch (e) { - _completer.completeError(e); - final Future sharedPrefsFuture = _completer.future; + _completer!.completeError(e); + final Future sharedPrefsFuture = _completer!.future; _completer = null; return sharedPrefsFuture; } } - return _completer.future; + return _completer!.future; } Future createOrUpdateEvents({List scheduleList, String title, String description, List scheduleDateTime, List daysOfWeek}) async { diff --git a/lib/uitl/HMGNetworkConnectivity.dart b/lib/uitl/HMGNetworkConnectivity.dart index 274f12d1..9ef3ce67 100644 --- a/lib/uitl/HMGNetworkConnectivity.dart +++ b/lib/uitl/HMGNetworkConnectivity.dart @@ -13,27 +13,27 @@ import 'package:diplomaticquarterapp/widgets/dialogs/alert_dialog.dart'; import 'package:diplomaticquarterapp/widgets/dialogs/confirm_dialog.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:wifi/wifi.dart'; +// import 'package:wifi/wifi.dart'; import 'gif_loader_dialog_utils.dart'; class HMGNetworkConnectivity { final _platformBridge = PlatformBridge.shared(); final BuildContext context; - Function callBack; + late Function callBack; final String GUEST_SSID = "HMG-MobileApp"; final String PATIENT_SSID = "GUEST-POC"; HMGNetworkConnectivity(this.context); - AuthenticatedUser userData; + late AuthenticatedUser userData; start() { - getUserData().then((value) { - userData = value; - checkAndConnectIfNoInternet(); - }); + // getUserData().then((value) { + // userData = value; + // checkAndConnectIfNoInternet(); + // }); } void checkAndConnectIfNoInternet() async { @@ -46,142 +46,103 @@ class HMGNetworkConnectivity { String pingUrl = "$BASE_URL$PING_SERVICE"; // pingUrl = "https://captive.apple.com"; - String ssid = await Wifi.ssid.catchError((error) { - log(error.toString()); - }); - - bool alreadyConnected = ssid == GUEST_SSID; + // String ssid = await Wifi.ssid.catchError((error) { + // log(error.toString()); + // }); - BaseAppClient().simpleGet(pingUrl, onSuccess: (dynamic response, int statusCode) { - log("Having internet with status code: $statusCode"); - }, onFailure: (String error, int statusCode) { - if (alreadyConnected) - showFailDailog(TranslationBase.of(context).failedToAccessHmgServices); - else { - confirmFromUser(connectForLocalAccess); + // bool alreadyConnected = ssid == GUEST_SSID; + + // BaseAppClient().simpleGet(pingUrl, onSuccess: (dynamic response, int statusCode) { + // log("Having internet with status code: $statusCode"); + // }, onFailure: (String error, int statusCode) { + // if (alreadyConnected) + // showFailDailog(TranslationBase.of(context).failedToAccessHmgServices); + // else { + // confirmFromUser(connectForLocalAccess); + // } + // }); + // } + + void confirmFromUser(VoidCallback confirmCallback) { + TranslationBase translator = TranslationBase.of(context); + + void doIt() { + ConfirmDialog( + context: context, + confirmMessage: translator.wantToConnectWithHmgNetwork, + okText: translator.yes, + okFunction: () { + // ConfirmDialog.closeAlertDialog(context); + confirmCallback(); + }, + cancelText: translator.no, + cancelFunction: () { + ConfirmDialog.closeAlertDialog(context); + }).showAlertDialog(context); } - }); - } - void confirmFromUser(VoidCallback confirmCallback) { - TranslationBase translator = TranslationBase.of(context); + // if (Platform.isAndroid) + // Wifi.list(GUEST_SSID).then((value) { + // if (!value.indexWhere((element) => element.ssid == GUEST_SSID).isNegative) doIt(); + // }); + // else + // doIt(); + } - void doIt() { - ConfirmDialog( + void showFailDailog(String message) { + TranslationBase translator = TranslationBase.of(context); + AlertDialogBox( context: context, - confirmMessage: translator.wantToConnectWithHmgNetwork, - okText: translator.yes, + okText: translator.ok, + confirmMessage: message, okFunction: () { - // ConfirmDialog.closeAlertDialog(context); - confirmCallback(); - }, - cancelText: translator.no, - cancelFunction: () { - ConfirmDialog.closeAlertDialog(context); + AlertDialogBox.closeAlertDialog(context); }).showAlertDialog(context); } - if (Platform.isAndroid) - Wifi.list(GUEST_SSID).then((value) { - if (!value.indexWhere((element) => element.ssid == GUEST_SSID).isNegative) doIt(); - }); - else - doIt(); - } - - void showFailDailog(String message) { - TranslationBase translator = TranslationBase.of(context); - AlertDialogBox( - context: context, - okText: translator.ok, - confirmMessage: message, - okFunction: () { - AlertDialogBox.closeAlertDialog(context); - }).showAlertDialog(context); - } - - Future getUserData() async { - var userData = AuthenticatedUser.fromJson(await AppSharedPreferences().getObject(MAIN_USER)); - return userData; - } + Future getUserData() async { + var userData = AuthenticatedUser.fromJson( + await AppSharedPreferences().getObject(MAIN_USER)); + return userData; + } - connectForLocalAccess() { - String patientID = userData.patientID.toString(); - GifLoaderDialogUtils.showMyDialog(context); - _platformBridge.connectHMGGuestWifi(GUEST_SSID).then((value) async { - if (value == 0) { - GifLoaderDialogUtils.hideDialog(context); - } else { - getPatientWifiCredentials(patientID, (username, password) async { - final result = await _platformBridge.connectHMGInternetWifi(PATIENT_SSID, username, password).catchError((err) => print(err.toString())); + connectForLocalAccess() { + String patientID = userData.patientID.toString(); + GifLoaderDialogUtils.showMyDialog(context); + _platformBridge.connectHMGGuestWifi(GUEST_SSID).then((value) async { + if (value == 0) { GifLoaderDialogUtils.hideDialog(context); - if (result == 1) { - // Success - } - }); - } - }); - } - - getPatientWifiCredentials(String patientID, Function(String username, String password) successCallback) { - final body = {"PatientID": patientID}; - locator().post(WIFI_CREDENTIALS, body: body, onSuccess: (dynamic response, int statusCode) { - print(response); - var data = response["Hmg_SMS_Get_By_ProjectID_And_PatientIDList"]; - if (data is List && data.first != null) { - final username = data.first['UserName']; - final password = data.first['Password']; - if (username != null && password != null && username.isNotEmpty && password.isNotEmpty) { - successCallback(username, password); + } else { + // getPatientWifiCredentials(patientID, (username, password) async { + // final result = await _platformBridge.connectHMGInternetWifi(PATIENT_SSID, username, password).catchError((err) => print(err.toString())); + // GifLoaderDialogUtils.hideDialog(context); + // if (result == 1) { + // // Success + // } + // }); } - } - }, onFailure: (String error, int statusCode) { - print(error); - }, bypassConnectionCheck: true); + }); + } + // + // getPatientWifiCredentials(String patientID, Function(String username, String password) successCallback) { + // final body = {"PatientID": patientID}; + // locator().post(WIFI_CREDENTIALS, body: body, onSuccess: (dynamic response, int statusCode) { + // print(response); + // var data = response["Hmg_SMS_Get_By_ProjectID_And_PatientIDList"]; + // if (data is List && data.first != null) { + // final username = data.first['UserName']; + // final password = data.first['Password']; + // if (username != null && password != null && username.isNotEmpty && password.isNotEmpty) { + // successCallback(username, password); + // } + // } + // }, onFailure: (String error, int statusCode) { + // print(error); + // }, bypassConnectionCheck: true); + // } + // + + } -// void next() { -// if (Platform.isIOS) { -// confirmFromUser_iOS(); -// } else if (Platform.isAndroid) { -// confirmFromUser(); -// } -// } - -// void confirmFromUser_iOS() { -// String message = "You don't have internet access, Do you want to connect with HMG Network to use App.\n\nMake sure you are in HMG Network range"; -// ConfirmDialog( -// context: context, -// confirmMessage: message, -// okText: "Yes", -// okFunction: () { -// ConfirmDialog.closeAlertDialog(context); -// callBack(); -// }, -// cancelText: "No", -// cancelFunction: () { -// ConfirmDialog.closeAlertDialog(context); -// }).showAlertDialog(context); -// } - -// void connect_Android() { -// // enable the Wifi if its off -// PlatformBridge() -// .enableWifiIfNot() -// .then((value) => { -// if (value == true) -// { -// callBack() -// // Wifi.list(SSID) -// // .then((value1) => { -// // if (value1.length > 0) {callBack()} else {log("No HMG network in range")} -// // }) -// // .catchError((e) { -// // log(e); -// // }) -// } -// }) -// .catchError((error) { -// showFailDailog(error); -// }); -// } + ///Commeneted code need to reimplement } diff --git a/lib/uitl/LocalNotification.dart b/lib/uitl/LocalNotification.dart index 9e0cd11b..d677e196 100644 --- a/lib/uitl/LocalNotification.dart +++ b/lib/uitl/LocalNotification.dart @@ -8,18 +8,18 @@ import 'package:flutter_local_notifications/flutter_local_notifications.dart'; final FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin(); class LocalNotification { - Function(String payload) _onNotificationClick; - static LocalNotification _instance; + Function(String payload)? _onNotificationClick; + static LocalNotification? _instance; - static LocalNotification getInstance() { + static LocalNotification? getInstance() { return _instance; } - static init({Function(String payload) onNotificationClick}) { + static init({required Function(String payload) onNotificationClick}) { if (_instance == null) { _instance = LocalNotification(); - _instance._onNotificationClick = onNotificationClick; - _instance._initialize(); + _instance?._onNotificationClick = onNotificationClick; + _instance?._initialize(); } else { // assert(false,(){ // //TODO fix it @@ -95,7 +95,7 @@ class LocalNotification { return vibrationPattern; } - Future showNow({@required String title, @required String subtitle, String payload}) { + Future? showNow({required String title, required String subtitle, required String payload}) { // Future.delayed(Duration(seconds: 1)).then((result) async { // var androidPlatformChannelSpecifics = AndroidNotificationDetails('com.hmg.local_notification', 'HMG', // channelDescription: 'HMG', importance: Importance.max, priority: Priority.high, ticker: 'ticker', vibrationPattern: _vibrationPattern()); @@ -107,7 +107,7 @@ class LocalNotification { // }); } - Future scheduleNotification({@required DateTime scheduledNotificationDateTime, @required String title, @required String description}) async { + Future scheduleNotification({required DateTime scheduledNotificationDateTime, required String title, required String description}) async { ///vibrationPattern var vibrationPattern = Int64List(4); vibrationPattern[0] = 0; diff --git a/lib/uitl/PlatformBridge.dart b/lib/uitl/PlatformBridge.dart index 3efeba9e..4dfc13a2 100644 --- a/lib/uitl/PlatformBridge.dart +++ b/lib/uitl/PlatformBridge.dart @@ -7,8 +7,8 @@ import 'package:flutter/services.dart'; class PlatformBridge { static const platform = const MethodChannel("HMG-Platform-Bridge"); - static PlatformBridge _shared; - static BuildContext _context; + static late PlatformBridge _shared; + static late BuildContext _context; // // Singleton // static final PlatformBridge _singleton = PlatformBridge._internal(); @@ -54,10 +54,10 @@ class PlatformBridge { //--------------------------------- // Incoming below //--------------------------------- - static Future localizedValue(String forKey) async { + static Future localizedValue(String forKey) async { String currentLanguage = await sharedPref.getStringWithDefaultValue(APP_LANGUAGE, 'ar'); - Object localized = platformLocalizedValues[forKey][currentLanguage]; - return (localized != null || (localized is String)) ? localized : forKey; + dynamic localized = platformLocalizedValues[forKey][currentLanguage]; + return (localized! != null || (localized! is String)) ? localized! : forKey!; } static Future getGeoZones() async { @@ -92,16 +92,16 @@ class PlatformBridge { static const ASK_DRAW_OVER_APPS_PERMISSION = "askDrawOverAppsPermission"; static const GET_INTENT = "getIntent"; - Future connectHMGInternetWifi(String ssid, username, password) { + Future connectHMGInternetWifi(String ssid, username, password) { try { - return platform.invokeMethod(hmg_internet_wifi_connect_method, [ssid, username,password]); + return platform!.invokeMethod(hmg_internet_wifi_connect_method!, [ssid!, username!,password!]); } on PlatformException catch (e) { print(e); return Future.error(e); } } - Future connectHMGGuestWifi(String ssid) { + Future connectHMGGuestWifi(String ssid) { try { return platform.invokeMethod(hmg_guest_wifi_connect_method, ssid); } on PlatformException catch (e) { @@ -110,7 +110,7 @@ class PlatformBridge { } } - Future isHMGNetworkAvailable(String ssid) { + Future isHMGNetworkAvailable(String ssid) { try { return platform.invokeMethod(is_hmg_network_available_method, ssid); } on PlatformException catch (e) { diff --git a/lib/uitl/cupertino_picker.dart b/lib/uitl/cupertino_picker.dart index d40d4b39..3dbbcea7 100644 --- a/lib/uitl/cupertino_picker.dart +++ b/lib/uitl/cupertino_picker.dart @@ -22,20 +22,20 @@ class CupertinoPickerUtils { /// [backgroundColor] background color showCupertinoPicker( - {BuildContext context, - List items, - String decKey, - Function onSelectFun, + {BuildContext? context, + List? items, + String? decKey, + Function? onSelectFun, bool isDismissible = false, double itemExtent = 25, bool looping = true, Color backgroundColor = const Color(0xfff7f7f7)}) { showModalBottomSheet( isDismissible: isDismissible, - context: context, + context: context!, builder: (BuildContext builder) { return Container( - height: SizeConfig.realScreenHeight * 0.4, + height: SizeConfig.realScreenHeight! * 0.4, color: backgroundColor, child: Column( mainAxisAlignment: MainAxisAlignment.end, @@ -60,22 +60,22 @@ class CupertinoPickerUtils { ), onPressed: () { Navigator.pop(context); - onSelectFun(cupertinoPickerIndex); + onSelectFun!(cupertinoPickerIndex); }, ), ], ), ), Container( - height: SizeConfig.realScreenHeight * 0.3, + height: SizeConfig.realScreenHeight! * 0.3, color: backgroundColor, child: buildPickerItems( context: context, - decKey: decKey, + decKey: decKey!, itemExtent: itemExtent, - items: items, + items: items!, looping: looping, - onSelectFun: onSelectFun)) + onSelectFun: onSelectFun!)) ], ), ); @@ -89,24 +89,24 @@ class CupertinoPickerUtils { /// [onSelectFun] the call function on select event /// [decKey] the key we show for user buildPickerItems( - {BuildContext context, - List items, - String decKey, - Function onSelectFun, - double itemExtent, - bool looping}) { + {BuildContext? context, + List? items, + String? decKey, + Function? onSelectFun, + double? itemExtent, + bool? looping}) { return CupertinoPicker( magnification: 1.5, scrollController: FixedExtentScrollController(initialItem: cupertinoPickerIndex), - children: items.map((item) { + children: items!.map((item) { return Text( '${item["$decKey"]}', - style: TextStyle(fontSize: SizeConfig.textMultiplier * 2), + style: TextStyle(fontSize: SizeConfig.textMultiplier! * 2), ); }).toList(), - itemExtent: itemExtent, - looping: looping, + itemExtent: itemExtent!, + looping: looping!, onSelectedItemChanged: (int index) { cupertinoPickerIndex = index; }, diff --git a/lib/uitl/date_uitl.dart b/lib/uitl/date_uitl.dart index cac6a07d..b97c00a5 100644 --- a/lib/uitl/date_uitl.dart +++ b/lib/uitl/date_uitl.dart @@ -238,7 +238,7 @@ class DateUtil { } static getMonthDateTime(String month, yearName) { - DateTime date; + DateTime? date; try { date = DateTime(int.parse(yearName), getMonthByName(month)); } catch (e) { diff --git a/lib/uitl/laser_body_parts_data.dart b/lib/uitl/laser_body_parts_data.dart index e52b4870..d7e5742d 100644 --- a/lib/uitl/laser_body_parts_data.dart +++ b/lib/uitl/laser_body_parts_data.dart @@ -102,29 +102,29 @@ class LaserBodyParts { "61": imagePng("assets/images/new/body_parts/female/bikini_line.png") }; - Widget getCategoryImage(bool isMale, int category, String mappingCode) { + Widget? getCategoryImage(bool isMale, int category, String mappingCode) { if (isMale) { if (category == 1) { - return maleBodyMap[mappingCode]; + return maleBodyMap![mappingCode]!; } if (category == 2) { - return maleFaceMap[mappingCode]; + return maleFaceMap![mappingCode]!; } if (category == 11) { - return maleBodyRetouchMap[mappingCode]; + return maleBodyRetouchMap![mappingCode]!; } } else { if (category == 1) { - return femaleBodyMap[mappingCode]; + return femaleBodyMap![mappingCode]!; } if (category == 2) { - return femaleFaceMap[mappingCode]; + return femaleFaceMap![mappingCode]!; } if (category == 10) { - return femaleBodyBikiniMap[mappingCode]; + return femaleBodyBikiniMap![mappingCode]!; } if (category == 11) { - return femaleBodyRetouchMap[mappingCode]; + return femaleBodyRetouchMap![mappingCode]!; } } return null; diff --git a/lib/uitl/location_util.dart b/lib/uitl/location_util.dart index 3eb6388f..d4ff7857 100644 --- a/lib/uitl/location_util.dart +++ b/lib/uitl/location_util.dart @@ -26,9 +26,9 @@ class LocationUtils { bool isHuawei; final GeolocatorPlatform _geolocatorPlatform = GeolocatorPlatform.instance; - LocationUtils({@required this.isShowConfirmDialog, @required this.context, this.isHuawei = false}); + LocationUtils({required this.isShowConfirmDialog, required this.context, this.isHuawei = false}); - void getCurrentLocation({Function(LatLng) callBack}) async { + void getCurrentLocation({required Function(LatLng) callBack}) async { if (Platform.isAndroid && isHuawei) { _getHMSCurrentLocation(callBack); } else { @@ -99,7 +99,7 @@ class LocationUtils { return true; } - LocationCallback _locationCallback; + late LocationCallback _locationCallback; _getHMSCurrentLocation(Function(LatLng) callBack) async { PermissionHandler permissionHandler = PermissionHandler(); @@ -117,10 +117,10 @@ class LocationUtils { _locationUpdateCbId = await locationService.requestLocationUpdatesCb( locationRequest, LocationCallback(onLocationResult: (locationResult) { - Location location = locationResult.lastLocation; + Location location = locationResult.lastLocation!; locationService.removeLocationUpdatesCb(_locationUpdateCbId); - callBack(LatLng(location.latitude, location.longitude)); - setLocation(Position(latitude: location.latitude, longitude: location.longitude, altitude: location.altitude)); + callBack(LatLng(location.latitude!, location.longitude!)); + setLocation(Position(latitude: location.latitude!, longitude: location.longitude!, altitude: location.altitude!,timestamp: null, accuracy: 1.0, heading: 0.0, speed: 0.0, speedAccuracy: 1)); }, onLocationAvailability: (locationAvailability) { print("onLocationAvailability: $locationAvailability"); })); @@ -168,6 +168,6 @@ class LocationUtils { var result = await [ Permission.location, ].request(); - return (result[Permission.location].isGranted || result[Permission.locationAlways].isGranted); + return (result[Permission.location]!.isGranted || result[Permission.locationAlways]!.isGranted); } } diff --git a/lib/uitl/navigation_service.dart b/lib/uitl/navigation_service.dart index a589249c..c48f8a79 100644 --- a/lib/uitl/navigation_service.dart +++ b/lib/uitl/navigation_service.dart @@ -10,21 +10,21 @@ class NavigationService { static Future navigateTo(String routeName) { final key = locator().navigatorKey; - return key.currentState.pushNamed(routeName); + return key.currentState!.pushNamed(routeName); } static Future navigateToPage(Widget page) { final key = locator().navigatorKey; final pageRoute = MaterialPageRoute(builder: (context) => page); - return Navigator.push(key.currentContext, pageRoute); + return Navigator.push(key.currentContext!, pageRoute); } } class Navigate{ - static to({@required Widget page}){ + static to({required Widget page}){ final context = locator().navigatorKey.currentContext; - Navigator.of(context).push(_pageRoute(page)); + Navigator.of(context!).push(_pageRoute(page)); } } -BuildContext get currentContext => locator().navigatorKey.currentContext; +BuildContext? get currentContext => locator().navigatorKey.currentContext; diff --git a/lib/uitl/push-notification-handler.dart b/lib/uitl/push-notification-handler.dart index 7ae1ba43..80e921a2 100644 --- a/lib/uitl/push-notification-handler.dart +++ b/lib/uitl/push-notification-handler.dart @@ -57,34 +57,34 @@ Future backgroundMessageHandler(dynamic message) async { // Push Notification Background <--| RemoteMessage toFirebaseRemoteMessage(h_push.RemoteMessage message) { - final payload_data = jsonDecode(message.data); + final payload_data = jsonDecode(message.data!); final fire_message = RemoteMessage( from: message.from, collapseKey: message.collapseKey, data: payload_data['data'], messageId: message.messageId, - sentTime: DateTime.fromMillisecondsSinceEpoch(message.sentTime * 1000), + sentTime: DateTime.fromMillisecondsSinceEpoch(message.sentTime! * 1000), ttl: message.ttl, category: null, messageType: message.type, notification: RemoteNotification( - title: message.notification.title, - titleLocArgs: (message.notification.titleLocalizationArgs ?? []).map((e) => e.toString()).toList(), - titleLocKey: message.notification.titleLocalizationKey, - body: message.notification.body, - bodyLocArgs: (message.notification.bodyLocalizationArgs ?? []).map((e) => e.toString()).toList(), - bodyLocKey: message.notification.bodyLocalizationKey, + title: message.notification!.title!, + titleLocArgs: (message.notification!.titleLocalizationArgs! ?? []).map((e) => e.toString()).toList(), + titleLocKey: message.notification!.titleLocalizationKey!, + body: message.notification!.body!, + bodyLocArgs: (message.notification!.bodyLocalizationArgs ?? []).map((e) => e.toString()).toList(), + bodyLocKey: message.notification!.bodyLocalizationKey, android: AndroidNotification( - channelId: message.notification.channelId, - clickAction: message.notification.clickAction, - color: message.notification.color, + channelId: message.notification!.channelId, + clickAction: message.notification!.clickAction, + color: message.notification!.color, count: null, - imageUrl: message.notification.imageUrl.path, - link: message.notification.link.path, - smallIcon: message.notification.icon, - sound: message.notification.sound, - ticker: message.notification.ticker, - tag: message.notification.tag, + imageUrl: message.notification!.imageUrl!.path, + link: message.notification!.link!.path, + smallIcon: message.notification!.icon, + sound: message.notification!.sound, + ticker: message.notification!.ticker, + tag: message.notification!.tag, ), )); return fire_message; @@ -102,11 +102,11 @@ callPage(String sessionID, String token) async { // } } -_incomingCall(Map data) async { +_incomingCall(Map data) async { LandingPage.incomingCallData = IncomingCallData.fromJson(data); if (LandingPage.isOpenCallPage == false) { LandingPage.isOpenCallPage = true; - final permited = await AppPermission.askVideoCallPermission(currentContext); + final permited = await AppPermission.askVideoCallPermission(currentContext!); if (permited) await NavigationService.navigateToPage(IncomingCall(incomingCallData: LandingPage.incomingCallData)); LandingPage.isOpenCallPage = false; } @@ -116,11 +116,11 @@ _incomingCall(Map data) async { class PushNotificationHandler { final BuildContext context; - static PushNotificationHandler _instance; + static late PushNotificationHandler _instance; final voIPKit = FlutterIOSVoIPKit.instance; - HmsApiAvailability hmsApiAvailability; + late HmsApiAvailability hmsApiAvailability; - Timer timeOutTimer; + late Timer timeOutTimer; bool isTalking = false; var data = { @@ -167,7 +167,7 @@ class PushNotificationHandler { // VoIP Callbacks voIPKit.getVoIPToken().then((value) { print('🎈 example: getVoIPToken: $value'); - AppSharedPreferences().setString(APNS_TOKEN, value); + AppSharedPreferences().setString(APNS_TOKEN, value!); }); voIPKit.onDidUpdatePushToken = ( @@ -241,7 +241,7 @@ class PushNotificationHandler { h_push.Push.getTokenStream.listen((token) { onToken(token); }, onError: (e) => print(e.toString())); - await h_push.Push.getToken(''); + h_push.Push.getToken(''); h_push.Push.registerBackgroundMessageHandler(backgroundMessageHandler); } else { @@ -262,13 +262,13 @@ class PushNotificationHandler { } else {} try { - FirebaseMessaging.instance.getInitialMessage().then((RemoteMessage message) async { - if (message != null) { + FirebaseMessaging.instance.getInitialMessage().then((RemoteMessage? message) async { + if (message! != null) { if (Platform.isIOS) await Future.delayed(Duration(milliseconds: 3000)).then((value) { - if (message != null) newMessage(message); + if (message! != null) newMessage(message!); }); - else if (message != null) newMessage(message); + else if (message! != null) newMessage(message!); } }); } catch (ex) {} @@ -298,9 +298,9 @@ class PushNotificationHandler { onToken(fcm_token); }); - FirebaseMessaging.instance.getToken(vapidKey: 'BHRJG8sIzcysWxPw3B6xQjz_85nUuCfU6EAmpH18kyUTmB2cj35IdFwCyWSab80SA1v6oBSWVh-p6PcHPw_y00Y').then((String token) { - print("Push Notification getToken: " + token); - onToken(token); + FirebaseMessaging.instance.getToken(vapidKey: 'BHRJG8sIzcysWxPw3B6xQjz_85nUuCfU6EAmpH18kyUTmB2cj35IdFwCyWSab80SA1v6oBSWVh-p6PcHPw_y00Y').then((String? token) { + print("Push Notification getToken: " + token!); + onToken(token!); }); FirebaseMessaging.onBackgroundMessage(backgroundMessageHandler); @@ -359,8 +359,8 @@ class PushNotificationHandler { } else if (Platform.isAndroid) { Permission.notification.request(); } - } catch (err) { - debugPrint(err); + } catch (_) { + debugPrint(_.toString()); } } } diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index 804cecdd..a95da21c 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -10,7 +10,7 @@ class TranslationBase { final Locale locale; static TranslationBase of(BuildContext context) { - return Localizations.of(context, TranslationBase); + return Localizations.of(context, TranslationBase)!; } String by(String key) { diff --git a/lib/uitl/utils.dart b/lib/uitl/utils.dart index d02f6120..b4763328 100644 --- a/lib/uitl/utils.dart +++ b/lib/uitl/utils.dart @@ -64,7 +64,7 @@ class Utils { ///show custom Error Toast /// [message] to show for user - static showErrorToast([String message]) { + static showErrorToast([String? message]) { String localMsg = generateContactAdminMessage(); if (message != null) { localMsg = message.toString(); @@ -98,14 +98,14 @@ class Utils { FocusScope.of(context).unfocus(); } - static showPermissionConsentDialog(BuildContext context, String message, Function onTap) { + static showPermissionConsentDialog(BuildContext context, String message, VoidCallback? onTap) { showDialog( context: context, builder: (cxt) => CovidConsentDialog( okTitle: TranslationBase.of(context).acceptLbl, title: TranslationBase.of(context).covidConsentHeader, message: message, - onTap: onTap, + onTap: onTap!, )); } @@ -160,7 +160,7 @@ class Utils { } bool validateIDBox(String value, type) { - Pattern pattern = loginIDPattern(type); //r'^\d+(?:\.\d+)?$'; + String pattern = loginIDPattern(type).toString(); //r'^\d+(?:\.\d+)?$'; RegExp regex = new RegExp(pattern); return regex.hasMatch(value); @@ -219,25 +219,25 @@ class Utils { return RegExp(r"^[a-zA-Z0-9.a-zA-Z0-9.!#$%&'*+-/=?^_`{|}~]+@[a-zA-Z0-9]+\.[a-zA-Z]+").hasMatch(email); } - static List myMedicalList({ProjectViewModel projectViewModel, BuildContext context, bool isLogin, count}) { + static List myMedicalList({ProjectViewModel? projectViewModel, BuildContext? context, bool? isLogin, count}) { List medical =[]; medical.add(InkWell( - onTap: () => projectViewModel.havePrivilege(5) ? Navigator.push(context, FadePage(page: MyAppointments())) : null, - child: isLogin + onTap: () => projectViewModel!.havePrivilege(5) ? Navigator.push(context!, FadePage(page: MyAppointments())) : null, + child: isLogin! ? Stack(children: [ Container( width: double.infinity, height: double.infinity, child: MedicalProfileItem( - title: TranslationBase.of(context).myAppointments, + title: TranslationBase.of(context!).myAppointments, imagePath: 'appointment_list.svg', - subTitle: TranslationBase.of(context).myAppointmentsList, + subTitle: TranslationBase.of(context!).myAppointmentsList, hasBadge: true, - isEnable: projectViewModel.havePrivilege(5)), + isEnable: projectViewModel!.havePrivilege(5)), ), projectViewModel.isArabic - ? !projectViewModel.user.isFamily + ? !projectViewModel.user!.isFamily ? Positioned( left: 8, top: 4, @@ -246,7 +246,7 @@ class Utils { elevation: 0, position: badge_import.BadgePosition.topEnd(), shape: badge_import.BadgeShape.circle, - badgeColor: secondaryColor.withOpacity(1.0), + badgeColor: secondaryColor!.withOpacity(1.0), borderRadius: BorderRadius.circular(8), badgeContent: Container( padding: EdgeInsets.all(2.0), @@ -255,7 +255,7 @@ class Utils { ), ) : Container() - : !projectViewModel.user.isFamily + : !projectViewModel.user!.isFamily ? Positioned( right: 8, top: 4, @@ -264,7 +264,7 @@ class Utils { elevation: 0, position: badge_import.BadgePosition.topEnd(), shape: badge_import.BadgeShape.circle, - badgeColor: secondaryColor.withOpacity(1.0), + badgeColor: secondaryColor!.withOpacity(1.0), borderRadius: BorderRadius.circular(8), badgeContent: Container( padding: EdgeInsets.all(2.0), @@ -275,11 +275,11 @@ class Utils { : Container(), ]) : MedicalProfileItem( - title: TranslationBase.of(context).myAppointments, + title: TranslationBase.of(context!).myAppointments, imagePath: 'appointment_list.svg', - subTitle: TranslationBase.of(context).myAppointmentsList, + subTitle: TranslationBase.of(context!).myAppointmentsList, hasBadge: true, - isEnable: projectViewModel.havePrivilege(5), + isEnable: projectViewModel!.havePrivilege(5), ), )); @@ -596,20 +596,20 @@ class Utils { }); } - static List myMedicalListHomePage({ProjectViewModel projectViewModel, BuildContext context, bool isLogin, count}) { + static List myMedicalListHomePage({ProjectViewModel? projectViewModel, BuildContext? context, bool? isLogin, count}) { List medical =[]; medical.add(InkWell( - onTap: () => projectViewModel.havePrivilege(5) ? Navigator.push(context, FadePage(page: MyAppointments())) : null, - child: isLogin + onTap: () => projectViewModel!.havePrivilege(5) ? Navigator.push(context!, FadePage(page: MyAppointments())) : null, + child: isLogin! ? Stack(children: [ MedicalProfileItem( - title: TranslationBase.of(context).myAppointments, + title: TranslationBase.of(context!).myAppointments, imagePath: 'appointment_list.svg', - subTitle: TranslationBase.of(context).myAppointmentsList, + subTitle: TranslationBase.of(context!).myAppointmentsList, hasBadge: true, - isEnable: projectViewModel.havePrivilege(5)), - projectViewModel.isArabic + isEnable: projectViewModel!.havePrivilege(5)), + projectViewModel.isArabic! ? !projectViewModel.isLoginChild ? Positioned( left: 8, @@ -619,7 +619,7 @@ class Utils { elevation: 0, position: badge_import.BadgePosition.topEnd(), shape: badge_import.BadgeShape.circle, - badgeColor: secondaryColor.withOpacity(1.0), + badgeColor: secondaryColor!.withOpacity(1.0), borderRadius: BorderRadius.circular(8), badgeContent: Container( padding: EdgeInsets.all(2.0), @@ -637,7 +637,7 @@ class Utils { elevation: 0, position: badge_import.BadgePosition.topEnd(), shape: badge_import.BadgeShape.circle, - badgeColor: secondaryColor.withOpacity(1.0), + badgeColor: secondaryColor!.withOpacity(1.0), borderRadius: BorderRadius.circular(8), badgeContent: Container( padding: EdgeInsets.all(2.0), @@ -648,11 +648,11 @@ class Utils { : Container(), ]) : MedicalProfileItem( - title: TranslationBase.of(context).myAppointments, + title: TranslationBase.of(context!).myAppointments, imagePath: 'appointment_list.svg', - subTitle: TranslationBase.of(context).myAppointmentsList, + subTitle: TranslationBase.of(context!).myAppointmentsList, hasBadge: true, - isEnable: projectViewModel.havePrivilege(5), + isEnable: projectViewModel!.havePrivilege(5), ), )); @@ -702,7 +702,7 @@ class Utils { return medical; } - static Widget loadNetworkImage({@required String url, BoxFit fitting = BoxFit.cover}) { + static Widget loadNetworkImage({required String url, BoxFit fitting = BoxFit.cover}) { return CachedNetworkImage( placeholderFadeInDuration: Duration(milliseconds: 250), fit: fitting, @@ -717,7 +717,7 @@ class Utils { }); } - static bool route(Route route, {@required Type equalsTo}) { + static bool route(Route route, {required Type equalsTo}) { if ((route is FadePage)) { return route.page.runtimeType == equalsTo; } @@ -725,7 +725,7 @@ class Utils { } static navigateToCartPage() { - Navigator.pushAndRemoveUntil(locator().navigatorKey.currentContext, MaterialPageRoute(builder: (context) => LandingPagePharmacy(currentTab: 3)), (Route r) => false); + Navigator.pushAndRemoveUntil(locator()!.navigatorKey!.currentContext!, MaterialPageRoute(builder: (context) => LandingPagePharmacy(currentTab: 3)), (Route r) => false); } static Widget tableColumnTitle(String text, {bool showDivider = true}) { @@ -749,7 +749,7 @@ class Utils { ); } - static Widget tableColumnValue(String text, {bool isLast = false, bool isCapitable = true, ProjectViewModel mProjectViewModel}) { + static Widget tableColumnValue(String text, {bool isLast = false, bool isCapitable = true, ProjectViewModel? mProjectViewModel}) { ProjectViewModel projectViewModel = mProjectViewModel ?? Provider.of(AppGlobal.context); return Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -820,13 +820,13 @@ class Utils { return isVidaPlus; } - static String generateSignature() { - - } + // static String generateSignature() { + // + // } } -Widget applyShadow({Color color = Colors.grey, double shadowOpacity = 0.5, double spreadRadius = 2, double blurRadius = 7, Offset offset = const Offset(2, 2), @required Widget child}) { +Widget applyShadow({Color color = Colors.grey, double shadowOpacity = 0.5, double spreadRadius = 2, double blurRadius = 7, Offset offset = const Offset(2, 2), required Widget child}) { return Container( decoration: BoxDecoration( boxShadow: [ @@ -855,7 +855,7 @@ extension IndexedIterable on Iterable { } } -openAppStore({String androidPackageName, String iOSAppID, bool isHuawei = false}) async { +openAppStore({String? androidPackageName, String? iOSAppID, bool isHuawei = false}) async { if (Platform.isAndroid) { assert(!(androidPackageName == null), "Should have valid value in androidPackageName parameter"); if (isHuawei) { @@ -869,7 +869,7 @@ openAppStore({String androidPackageName, String iOSAppID, bool isHuawei = false} } } -String labelFrom({@required String className}) { +String labelFrom({required String className}) { RegExp exp = RegExp(r'(?<=[a-z])[A-Z]'); String result = className.replaceAllMapped(exp, (m) { diff --git a/lib/uitl/utils_new.dart b/lib/uitl/utils_new.dart index 822137cd..74b7231a 100644 --- a/lib/uitl/utils_new.dart +++ b/lib/uitl/utils_new.dart @@ -133,11 +133,11 @@ InputDecoration txtFieldSearch(String label) { Widget circularAviator( double s, { - Color bcColor, - Color brColor, - Color iconColor, - int borderWidth, - IconData icon, + Color? bcColor, + Color? brColor, + Color? iconColor, + double? borderWidth, + IconData? icon, double elevation = 4, }) { return Card( @@ -148,10 +148,10 @@ Widget circularAviator( width: s, height: s, decoration: containerColorRadiusBorderWidth( - bcColor == null ? Colors.grey[200] : bcColor, + bcColor! == null ? Colors.grey[200]! : bcColor, 2000, - brColor == null ? Colors.blueGrey[800] : brColor, - borderWidth == null ? 2 : borderWidth), + brColor == null ? Colors.blueGrey[800]! : brColor, + borderWidth! == null ? 2 : borderWidth!), child: Icon( icon == null ? Icons.person : icon, size: s / 1.7, @@ -234,7 +234,7 @@ RoundedRectangleBorder buttonShape() { } Decoration containerRadiusWithGradient(double radius, - {Color color1, Color color2}) { + {Color? color1, Color? color2}) { return BoxDecoration( borderRadius: BorderRadius.circular(radius), gradient: LinearGradient( @@ -249,7 +249,7 @@ Decoration containerRadiusWithGradient(double radius, } Decoration containerBottomRightRadiusWithGradient(double radius, - {Color darkColor, Color lightColor}) { + {Color? darkColor, Color? lightColor}) { return BoxDecoration( borderRadius: BorderRadius.only(bottomRight: Radius.circular(radius)), gradient: LinearGradient( @@ -264,7 +264,7 @@ Decoration containerBottomRightRadiusWithGradient(double radius, } Decoration containerBottomRightRadiusWithGradientForAr(double radius, - {Color darkColor, Color lightColor}) { + {Color? darkColor, Color? lightColor}) { return BoxDecoration( borderRadius: BorderRadius.only(bottomLeft: Radius.circular(radius)), gradient: LinearGradient( @@ -280,8 +280,8 @@ Decoration containerBottomRightRadiusWithGradientForAr(double radius, Decoration containerRadiusWithGradientServices( double radius, { - Color darkColor, - Color lightColor, + Color? darkColor, + Color? lightColor, bool isProduct = false, bool prescriptionRequired = false, bool isEnglish = true, @@ -308,8 +308,8 @@ Decoration containerRadiusWithGradientServices( } Decoration containerBottomRightRadiusWithGradientBorder(double radius, - {Color darkColor, - Color lightColor, + {Color? darkColor, + Color? lightColor, Color borderColor = Colors.transparent, double w = 0}) { return BoxDecoration( @@ -453,7 +453,7 @@ Decoration containerColorRadiusLeftBorder( ); } -BoxDecoration cardRadius(double radius, {Color color, double elevation}) { +BoxDecoration cardRadius(double radius, {Color? color, double? elevation}) { return BoxDecoration( shape: BoxShape.rectangle, color: color ?? Colors.white, diff --git a/lib/widgets/app_map/google_huawei_map.dart b/lib/widgets/app_map/google_huawei_map.dart index 1f7aed92..d9641247 100644 --- a/lib/widgets/app_map/google_huawei_map.dart +++ b/lib/widgets/app_map/google_huawei_map.dart @@ -9,17 +9,18 @@ import 'package:google_maps_flutter/google_maps_flutter.dart' as googlemap; import 'package:huawei_hmsavailability/huawei_hmsavailability.dart'; import 'package:huawei_map/components/callbacks.dart'; import 'package:huawei_map/components/cameraPosition.dart' as cameraposition; +import 'package:huawei_map/components/cameraPosition.dart'; import 'package:huawei_map/map.dart' as hmsMap; class AppMap extends StatefulWidget { - late CameraPositionCallback? onCameraMove; + late VoidCallback onCameraMove; late Map initialCamera; AppMapState? _state; late Function? onMapCreated; late Function? onCameraIdle; - AppMap(this.initialCamera, { this.onCameraMove, this.onMapCreated, this.onCameraIdle}); + AppMap(this.initialCamera, { required this.onCameraMove, this.onMapCreated, this.onCameraIdle}); @override State createState() => _state = AppMapState(); @@ -76,8 +77,10 @@ class AppMapState extends State { zoomControlsEnabled: true, myLocationButtonEnabled: true, myLocationEnabled: true, - initialCameraPosition: googlemap.CameraPosition.fromMap(widget.initialCamera), - onCameraMove: widget.onCameraMove, + initialCameraPosition: googlemap.CameraPosition.fromMap!(widget.initialCamera)!, + onCameraMove: (camera) { + widget.onCameraMove; + }, onMapCreated: (googlemap.GoogleMapController controller) { googleMapController = controller; _googleMapControllerComp.complete(controller); @@ -97,7 +100,7 @@ class AppMapState extends State { myLocationButtonEnabled: true, myLocationEnabled: true, initialCameraPosition: hmsMap.CameraPosition.fromMap(widget.initialCamera), - onCameraMove: (camera) => widget.onCameraMove!(CameraPosition.fromMap(camera.toMap())), + onCameraMove: (camera) => widget.onCameraMove!, onMapCreated: (controller) { _huaweiMapController = controller; _huaweiMapControllerComp.complete(controller); diff --git a/lib/widgets/avatar/large_avatar.dart b/lib/widgets/avatar/large_avatar.dart index 131a2820..348f76da 100644 --- a/lib/widgets/avatar/large_avatar.dart +++ b/lib/widgets/avatar/large_avatar.dart @@ -14,19 +14,19 @@ import '../show_zoom_image_dialog.dart'; /// [height] the avatar height /// [onTap] on tap function class LargeAvatar extends StatelessWidget { - LargeAvatar({Key key, @required this.name, this.url, this.disableProfileView: false, this.radius = 70.0, this.width = 70, this.height = 60, this.onTap, this.isAppointmentAvatar: false}) : super(key: key); + LargeAvatar({Key? key, required this.name, this.url, this.disableProfileView= false, this.radius = 70.0, this.width = 70, this.height = 60, this.onTap, this.isAppointmentAvatar= false}) : super(key: key); - final String name; - final String url; + final String? name; + final String? url; final bool disableProfileView; final bool isAppointmentAvatar; final double radius; final double width; final double height; - final GestureTapCallback onTap; + final GestureTapCallback? onTap; Widget _getAvatar() { - if (url != null && url.isNotEmpty && Uri.parse(url).isAbsolute) { + if (url != null && url!.isNotEmpty && Uri.parse(url!).isAbsolute) { return Center( child: ClipRRect( borderRadius: BorderRadius.all(Radius.circular(radius)), @@ -34,7 +34,7 @@ class LargeAvatar extends StatelessWidget { alignment: Alignment.center, children: [ Image.network( - url.trim(), + url!.trim(), fit: BoxFit.fill, width: width, height: height, @@ -52,7 +52,7 @@ class LargeAvatar extends StatelessWidget { } else return Center( child: Texts( - name[0].toUpperCase(), + name![0].toUpperCase(), color: Colors.white, fontSize: 18, )); @@ -64,8 +64,8 @@ class LargeAvatar extends StatelessWidget { onTap: disableProfileView ? null : isAppointmentAvatar ? onTap : () { - print("ssssss " + url.trim()); - showZoomImageDialog(context, url.trim() ?? ""); + print("ssssss " + url!.trim()); + showZoomImageDialog(context, url!.trim() ?? ""); }, child: Container( decoration: BoxDecoration( diff --git a/lib/widgets/bottom_navigation/bottom_nav_bar.dart b/lib/widgets/bottom_navigation/bottom_nav_bar.dart index 6f27fd94..c5bd76a3 100644 --- a/lib/widgets/bottom_navigation/bottom_nav_bar.dart +++ b/lib/widgets/bottom_navigation/bottom_nav_bar.dart @@ -13,10 +13,10 @@ import '../../d_q_icons_icons.dart'; import 'bottom_navigation_item.dart'; class BottomNavBar extends StatefulWidget { - final ValueChanged changeIndex; - final int index; + final ValueChanged? changeIndex; + final int? index; final bool showHomeIcon; - BottomNavBar({Key key, this.changeIndex, this.index, this.showHomeIcon = false}) : super(key: key); + BottomNavBar({Key? key, this.changeIndex, this.index, this.showHomeIcon = false}) : super(key: key); @override _BottomNavBarState createState() => _BottomNavBarState(); @@ -24,10 +24,10 @@ class BottomNavBar extends StatefulWidget { class _BottomNavBarState extends State { int _index = 0; - ToDoCountProviderModel model; + ToDoCountProviderModel? model; var event = RobotProvider(); _changeIndex(int index) async { - widget.changeIndex(index); + widget.changeIndex!(index); if (index == 5) { event.setValue({'isRobotVisible': 'true'}); } diff --git a/lib/widgets/bottom_navigation/bottom_navigation_item.dart b/lib/widgets/bottom_navigation/bottom_navigation_item.dart index f7cdafce..8ad2aa18 100644 --- a/lib/widgets/bottom_navigation/bottom_navigation_item.dart +++ b/lib/widgets/bottom_navigation/bottom_navigation_item.dart @@ -12,13 +12,13 @@ import 'package:provider/provider.dart'; import '../../Constants.dart'; class BottomNavigationItem extends StatelessWidget { - final String icon; - final String activeIcon; - final ValueChanged changeIndex; - final int index; - final int currentIndex; - final String name; - final bool isDisabled; + final String? icon; + final String? activeIcon; + final ValueChanged? changeIndex; + final int? index; + final int? currentIndex; + final String? name; + final bool? isDisabled; AuthenticatedUserObject authenticatedUserObject = locator(); @@ -37,7 +37,7 @@ class BottomNavigationItem extends StatelessWidget { highlightColor: Colors.transparent, splashColor: Colors.transparent, onTap: () { - if (!isDisabled) changeIndex(currentIndex); + if (!isDisabled!) changeIndex!(currentIndex!); }, child: currentIndex != 4 ? Column( @@ -48,9 +48,9 @@ class BottomNavigationItem extends StatelessWidget { height: 15, ), icon == "assets/images/new/bottom_nav/help.svg" ? Container( - child: SvgPicture.asset(icon, height: 20, width: 20, fit: BoxFit.cover), + child: SvgPicture.asset(icon!, height: 20, width: 20, fit: BoxFit.cover), ) : Container( - child: SvgPicture.asset(icon, height: 20, width: 20, fit: BoxFit.cover, color: currentIndex == index + child: SvgPicture.asset(icon!, height: 20, width: 20, fit: BoxFit.cover, color: currentIndex == index ? Color(0xff333c45) : Color(0xff989898)), ), @@ -62,7 +62,7 @@ class BottomNavigationItem extends StatelessWidget { textAlign: TextAlign.center, color: currentIndex == index ? Color(0xff333c45) - : isDisabled + : isDisabled! ? Colors.grey[300] : Colors.grey, fontSize: 11, @@ -84,7 +84,7 @@ class BottomNavigationItem extends StatelessWidget { height: 15, ), Container( - child: SvgPicture.asset(icon, height: 20, width: 20, fit: BoxFit.cover, color: currentIndex == index + child: SvgPicture.asset(icon!, height: 20, width: 20, fit: BoxFit.cover, color: currentIndex == index ? Color(0xff333c45) : Color(0xff989898)), // Icon(currentIndex == index ? activeIcon : icon, color: currentIndex == index ? secondaryColor : Theme.of(context).dividerColor, size: 22.0), @@ -110,7 +110,7 @@ class BottomNavigationItem extends StatelessWidget { toAnimate: false, position: badge_import.BadgePosition.topEnd(), shape: badge_import.BadgeShape.circle, - badgeColor: secondaryColor.withOpacity(1.0), + badgeColor: secondaryColor!.withOpacity(1.0), borderRadius: BorderRadius.circular(8), badgeContent: Container( padding: EdgeInsets.all(2.0), @@ -128,7 +128,7 @@ class BottomNavigationItem extends StatelessWidget { height: 15, ), Container( - child: SvgPicture.asset(icon, height: 20, width: 20, fit: BoxFit.cover), + child: SvgPicture.asset(icon!, height: 20, width: 20, fit: BoxFit.cover), ), SizedBox( height: 2, @@ -138,7 +138,7 @@ class BottomNavigationItem extends StatelessWidget { textAlign: TextAlign.center, color: currentIndex == index ? Color(0xff333c45) - : isDisabled + : isDisabled! ? Colors.grey[300] : Colors.grey, fontSize: 11, diff --git a/lib/widgets/bottom_options/BottomSheet.dart b/lib/widgets/bottom_options/BottomSheet.dart index 5399a4c3..04568632 100644 --- a/lib/widgets/bottom_options/BottomSheet.dart +++ b/lib/widgets/bottom_options/BottomSheet.dart @@ -32,7 +32,7 @@ class ImageOptions { if (Platform.isAndroid) { galleryImageAndroid(image); } else { - File _image = File((await ImagePicker.platform.pickImage(source: ImageSource.gallery, imageQuality: 20)).path); + File _image = File((await ImagePicker.platform.pickImage(source: ImageSource.gallery, imageQuality: 20))!.path); String fileName = _image.path; final bytes = File(fileName).readAsBytesSync(); String base64Encode = base64.encode(bytes); @@ -49,7 +49,7 @@ class ImageOptions { if (Platform.isAndroid) { cameraImageAndroid(image); } else { - File _image = File((await ImagePicker.platform.pickImage(source: ImageSource.camera, imageQuality: 20)).path); + File _image = File((await ImagePicker.platform.pickImage(source: ImageSource.camera, imageQuality: 20))!.path); String fileName = _image.path; final bytes = File(fileName).readAsBytesSync(); String base64Encode = base64.encode(bytes); @@ -71,7 +71,7 @@ class ImageOptions { galleryImageAndroid(Function(String, File) image) async { if(await PermissionService.isExternalStorageEnabled()) { - File _image = File((await ImagePicker.platform.pickImage(source: ImageSource.gallery, imageQuality: 20)).path); + File _image = File((await ImagePicker.platform.pickImage(source: ImageSource.gallery, imageQuality: 20))!.path); String fileName = _image.path; final bytes = File(fileName).readAsBytesSync(); String base64Encode = base64.encode(bytes); @@ -80,7 +80,7 @@ galleryImageAndroid(Function(String, File) image) async { } } else { Utils.showPermissionConsentDialog(AppGlobal.context, TranslationBase.of(AppGlobal.context).galleryPermission, () async { - File _image = File((await ImagePicker.platform.pickImage(source: ImageSource.gallery, imageQuality: 20)).path); + File _image = File((await ImagePicker.platform.pickImage(source: ImageSource.gallery, imageQuality: 20))!.path); String fileName = _image.path; final bytes = File(fileName).readAsBytesSync(); String base64Encode = base64.encode(bytes); @@ -93,7 +93,7 @@ galleryImageAndroid(Function(String, File) image) async { cameraImageAndroid(Function(String, File) image) async { if (await PermissionService.isCameraEnabled()) { - File _image = File((await ImagePicker.platform.pickImage(source: ImageSource.camera, imageQuality: 20)).path); + File _image = File((await ImagePicker.platform.pickImage(source: ImageSource.camera, imageQuality: 20))!.path); String fileName = _image.path; final bytes = File(fileName).readAsBytesSync(); String base64Encode = base64.encode(bytes); @@ -102,7 +102,7 @@ cameraImageAndroid(Function(String, File) image) async { } } else { Utils.showPermissionConsentDialog(AppGlobal.context, TranslationBase.of(AppGlobal.context).cameraPermissionDialog, () async { - File _image = File((await ImagePicker.platform.pickImage(source: ImageSource.camera, imageQuality: 20)).path); + File _image = File((await ImagePicker.platform.pickImage(source: ImageSource.camera, imageQuality: 20))!.path); String fileName = _image.path; final bytes = File(fileName).readAsBytesSync(); String base64Encode = base64.encode(bytes); @@ -116,7 +116,7 @@ cameraImageAndroid(Function(String, File) image) async { class _BottomSheet extends StatelessWidget { final List children; - _BottomSheet({Key key, @required this.children}) : super(key: key); + _BottomSheet({Key? key, required this.children}) : super(key: key); @override Widget build(BuildContext context) { @@ -142,12 +142,12 @@ class _BottomSheet extends StatelessWidget { } class _BottomSheetItem extends StatelessWidget { - final Function onTap; - final IconData icon; + final Function? onTap; + final IconData? icon; final String title; final ITEM_COLOR color; - _BottomSheetItem({Key key, this.onTap, @required this.title, this.icon, this.color = ITEM_COLOR.primary}) : super(key: key); + _BottomSheetItem({Key? key, this.onTap, required this.title, this.icon, this.color = ITEM_COLOR.primary}) : super(key: key); @override Widget build(BuildContext context) { @@ -155,7 +155,7 @@ class _BottomSheetItem extends StatelessWidget { onTap: () { if (onTap != null) { Navigator.pop(context); - onTap(); + onTap!(); } }, child: Padding( diff --git a/lib/widgets/buttons/BottomButton.dart b/lib/widgets/buttons/BottomButton.dart index 3e85aa1e..f4aafdb4 100644 --- a/lib/widgets/buttons/BottomButton.dart +++ b/lib/widgets/buttons/BottomButton.dart @@ -14,17 +14,17 @@ import 'package:flutter/material.dart'; class BottomButton extends StatelessWidget { final bool loading; final bool disabled; - final String label; - final Widget icon; - final Color color; - final Color textColor; - final Color borderColor; - final Function onTap; - final Widget child; + final String? label; + final Widget? icon; + final Color? color; + final Color? textColor; + final Color? borderColor; + final Function? onTap; + final Widget? child; final bool disabledPadding; BottomButton( - {Key key, + {Key? key, this.loading = false, this.disabled = false, this.label, @@ -121,11 +121,11 @@ class BottomButton extends StatelessWidget { child: SecondaryButton( borderColor: borderColor, onTap: () { - if (onTap != null) onTap(); + if (onTap != null) onTap!(); }, loading: loading, disabled: disabled, - label: label, + label: label!, icon: icon, color: color, textColor: textColor), diff --git a/lib/widgets/buttons/GestureIconButton.dart b/lib/widgets/buttons/GestureIconButton.dart index 40f8ceaf..5ad13362 100644 --- a/lib/widgets/buttons/GestureIconButton.dart +++ b/lib/widgets/buttons/GestureIconButton.dart @@ -29,7 +29,7 @@ class _GestureIconButtonState extends State { setState(() { _buttonLongPress = !_buttonLongPress; }); - widget.onTap(); + widget.onTap!(); }, // onLongPressStart: (_) => @@ -39,9 +39,9 @@ class _GestureIconButtonState extends State { child: Container( decoration: BoxDecoration( border: Border.all( - color: widget.backgroundColor != null - ? widget.backgroundColor - : Colors.grey[200], + color: widget.backgroundColor! != null + ? widget.backgroundColor! + : Colors.grey[200]!, ), color: widget.backgroundColor != null ? widget.backgroundColor diff --git a/lib/widgets/buttons/borderedButton.dart b/lib/widgets/buttons/borderedButton.dart index b0bbdaf0..85c7e78a 100644 --- a/lib/widgets/buttons/borderedButton.dart +++ b/lib/widgets/buttons/borderedButton.dart @@ -2,12 +2,12 @@ import 'package:diplomaticquarterapp/config/size_config.dart'; import 'package:flutter/material.dart'; class BorderedButton extends StatelessWidget { - final String text; - final Function handler; - final Color textColor; + final String? text; + final Function? handler; + final Color? textColor; final bool hasBorder; - final Color borderColor; - final Color backgroundColor; + final Color? borderColor; + final Color? backgroundColor; final double vPadding; final double hPadding; final double radius; @@ -16,8 +16,8 @@ class BorderedButton extends StatelessWidget { final double rPadding; final double bPadding; final double fontSize; - final Widget icon; - final FontWeight fontWeight; + final Widget? icon; + final FontWeight? fontWeight; final bool hasShadow; BorderedButton( @@ -44,7 +44,7 @@ class BorderedButton extends StatelessWidget { Widget build(BuildContext context) { return GestureDetector( onTap: () { - handler(); + handler!(); }, child: Container( decoration: BoxDecoration( @@ -52,7 +52,7 @@ class BorderedButton extends StatelessWidget { color: backgroundColor ?? Colors.white, borderRadius: BorderRadius.circular(radius), border: Border.fromBorderSide(BorderSide( - color: hasBorder ? borderColor : Colors.white, + color: hasBorder! ? borderColor! : Colors.white, width: 0.8, )), boxShadow: [ @@ -67,7 +67,7 @@ class BorderedButton extends StatelessWidget { child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - icon != null ? icon : Container(), + icon != null ? icon! : Container(), Container( padding: (hPadding > 0 || vPadding > 0) ? EdgeInsets.symmetric( @@ -75,11 +75,11 @@ class BorderedButton extends StatelessWidget { : EdgeInsets.fromLTRB( lPadding, tPadding, rPadding, bPadding), child: Text( - text, + text!, textAlign: TextAlign.center, style: TextStyle( fontSize: fontSize == 0 - ? SizeConfig.textMultiplier * 1.6 + ? SizeConfig.textMultiplier! * 1.6 : fontSize, fontWeight: fontWeight != null ? fontWeight : FontWeight.normal, diff --git a/lib/widgets/buttons/button.dart b/lib/widgets/buttons/button.dart index 84f3cca6..723a8590 100644 --- a/lib/widgets/buttons/button.dart +++ b/lib/widgets/buttons/button.dart @@ -10,14 +10,14 @@ import 'package:provider/provider.dart'; /// [loading] show the progress indicator /// [elevation] color elevation value class Button extends StatefulWidget { - Button({Key key, this.label: "", this.icon, this.onTap, this.backgroundColor, this.loading: false, this.elevation: true, this.disabled = false}) : super(key: key); + Button({Key? key, this.label= "", this.icon, this.onTap, this.backgroundColor, this.loading= false, this.elevation= true, this.disabled = false}) : super(key: key); final String label; - final Widget icon; - final VoidCallback onTap; + final Widget? icon; + final VoidCallback? onTap; final bool loading; final bool elevation; - final Color backgroundColor; + final Color? backgroundColor; final bool disabled; @override @@ -26,17 +26,17 @@ class Button extends StatefulWidget { class _ButtonState extends State