From fe8ac14e46a48961d70289f201f933a1a3bbb23f Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Tue, 10 Sep 2024 16:49:41 +0300 Subject: [PATCH] sdk upgrade changes-1. --- lib/controllers/api_routes/api_manager.dart | 35 +- .../firebase_notification_manger.dart | 14 +- .../notification/notification_manger.dart | 32 +- .../providers/api/all_requests_provider.dart | 180 ++++---- .../providers/api/gas_refill_provider.dart | 8 +- .../providers/api/ppm_provider.dart | 4 +- ...reventive_maintenance_visits_provider.dart | 8 +- .../api/service_requests_provider.dart | 73 ++-- ...e_report_assistants_employee_provider.dart | 55 +-- .../service_report_last_calls_provider.dart | 37 +- ...rvice_report_repair_location_provider.dart | 12 +- .../report/service_types_provider.dart | 17 +- .../providers/api/user_provider.dart | 82 ++-- lib/dashboard_latest/dashboard_view.dart | 24 +- .../widgets/app_bar_widget.dart | 2 +- lib/extensions/int_extensions.dart | 4 +- lib/main.dart | 2 +- lib/models/device/asset_by_id_model.dart | 312 ++++++------- lib/models/device/asset_transfer.dart | 286 ++++++------ lib/models/lookup.dart | 24 +- .../call_site_contact_person.dart | 63 +-- .../contact_person_work_order.dart | 32 +- .../pending_service_request_model.dart | 18 +- .../service_request/search_work_order.dart | 267 ++++++------ .../service_request/service_report.dart | 210 ++++----- .../service_request/service_request.dart | 96 ++-- .../service_request_search.dart | 40 +- lib/models/service_request/spare_parts.dart | 58 +-- .../supp_engineer_work_orders.dart | 35 +- .../service_request/supplier_details.dart | 196 ++++----- .../supplier_engineer_model.dart | 12 +- .../service_request/wo_call_request.dart | 72 +-- lib/models/service_request/wo_parent.dart | 99 ++--- lib/models/subtitle.dart | 408 ++++++++--------- lib/new_views/app_style/app_themes.dart | 8 +- .../common_widgets/app_bottom_nav_bar.dart | 10 +- .../common_widgets/app_dashed_button.dart | 2 +- lib/new_views/common_widgets/app_drawer.dart | 19 +- .../common_widgets/app_filled_button.dart | 18 +- .../app_floating_action_button.dart | 7 +- .../common_widgets/app_lazy_loading.dart | 2 +- .../common_widgets/app_loading_manager.dart | 43 +- .../common_widgets/app_search_field.dart | 72 +-- lib/new_views/common_widgets/app_tab_bar.dart | 2 +- .../common_widgets/app_text_form_field.dart | 75 ++-- .../common_widgets/asset_info_card.dart | 4 +- .../common_widgets/custom_app_bar.dart | 10 +- .../common_widgets/custom_badge.dart | 6 +- .../common_widgets/default_app_bar.dart | 6 +- .../single_item_drop_down_menu.dart | 150 +++---- lib/new_views/common_widgets/tab_button.dart | 20 +- lib/new_views/pages/help_center_page.dart | 4 +- .../pages/land_page/calendar_page.dart | 4 +- .../calender_fragments/calendar_header.dart | 2 +- .../calender_days_card.dart | 2 +- .../calender_fragments/daily_fragment.dart | 8 +- .../calender_fragments/monthly_fragment.dart | 27 +- .../calender_fragments/weekly_fragment.dart | 22 +- .../land_page/contact_us_bottom_sheet.dart | 2 +- .../progress_fragment.dart | 20 +- .../recent_activites_fragment.dart | 8 +- .../request_category_fragment.dart | 22 +- .../request_category_list.dart | 2 +- .../requests_fragment.dart | 16 +- .../pages/land_page/dashboard_page.dart | 16 +- .../pages/land_page/home_app_bar.dart | 2 +- lib/new_views/pages/land_page/land_page.dart | 12 +- .../my_request/all_requests_filter_page.dart | 60 +-- .../my_request/all_requests_search_page.dart | 60 +-- .../my_request/my_requests_page.dart | 36 +- .../land_page/requests/asset_item_view.dart | 10 +- .../requests/gas_refill_item_view.dart | 18 +- .../land_page/requests/ppm_item_view.dart | 14 +- .../requests/request_paginated_listview.dart | 2 +- .../requests/service_request_item_view.dart | 23 +- .../pages/land_page/requests_list_page.dart | 58 ++- .../widgets/request_item_view_list.dart | 2 +- .../widgets/request_search_buttons.dart | 6 +- .../widgets/static_filter_buttons.dart | 4 +- lib/new_views/pages/login_page.dart | 43 +- .../pages/new_gas_refill_request_page.dart | 42 +- lib/new_views/pages/report_bug_page.dart | 7 +- lib/new_views/pages/settings_page.dart | 51 +-- lib/new_views/pages/splash_page.dart | 10 +- lib/providers/loading_list_notifier.dart | 6 +- lib/providers/work_order/reason_provider.dart | 4 +- .../components/activities_list_view.dart | 28 +- .../views/components/activity_card_view.dart | 18 +- .../bottom_sheets/action_bottomsheet.dart | 173 ++++---- .../activity_type_bottomsheet.dart | 20 +- .../initial_visit_bottomsheet.dart | 10 +- .../reject_request_bottomsheet.dart | 411 +++++++++--------- .../service_request_bottomsheet.dart | 16 +- .../views/components/history_log_view.dart | 14 +- .../views/components/request_detail_view.dart | 408 +++++++++-------- .../views/components/scan_qr_view.dart | 6 +- .../views/components/spare_part_request.dart | 29 +- .../views/components/verify_arrival_view.dart | 74 ++-- .../views/components/verify_otp_view.dart | 2 +- .../views/request_detail_main_view.dart | 2 +- lib/utilities/general_utils.dart | 2 +- lib/utilities/request_utils.dart | 2 +- .../device_transfer/asset_filter_screen.dart | 2 +- .../device_transfer/asset_search_screen.dart | 2 +- .../device_transfer_details.dart | 4 +- .../request_device_transfer.dart | 2 +- .../device_transfer/search_asset_page.dart | 2 +- .../track_device_transfer.dart | 2 +- .../update_device_transfer.dart | 2 +- lib/views/pages/splash_screen.dart | 2 +- .../auto_generated_vendor_name.dart | 2 +- .../create_sub_workorder_page.dart | 2 +- .../search_sub_workorder_page.dart | 2 +- .../spare_parts_details_bottom_sheet.dart | 2 +- .../work_order_details_bottom_sheet.dart | 2 +- .../sub_workorder/workorder_details.dart | 2 +- .../pages/sub_workorder/workorder_item.dart | 2 +- .../pages/sub_workorder/workorder_list.dart | 2 +- .../pages/sub_workorder/workorder_update.dart | 2 +- .../user/gas_refill/gas_refill_comments.dart | 2 +- .../user/gas_refill/gas_refill_details.dart | 2 +- .../user/gas_refill/request_gas_refill.dart | 2 +- .../user/gas_refill/track_gas_refill.dart | 2 +- lib/views/pages/user/land_page.dart | 2 +- .../notifications/notifications_list.dart | 2 +- .../pages/user/ppm/ppm_details_page.dart | 2 +- lib/views/pages/user/ppm/ppm_page.dart | 2 +- .../pages/user/ppm/update_ppm/edit_ppm.dart | 2 +- .../user/ppm/update_ppm/future_edit_ppm.dart | 2 +- lib/views/pages/user/profile_page.dart | 2 +- lib/views/pages/user/report_issues_page.dart | 2 +- .../add_supplier_engineer_bottom_sheet.dart | 2 +- .../user/requests/comments_bottom_sheet.dart | 2 +- .../requests/create_service_request_page.dart | 4 +- .../requests/first_action_bottom_sheet.dart | 2 +- .../requests/pending_requests_screen.dart | 2 +- .../requests/service_request_details.dart | 2 +- .../requests/update_service_request_page.dart | 2 +- .../work_order/create_service_report.dart | 6 +- .../work_order/edit_service_report.dart | 7 +- .../requests/work_order/part_no_button.dart | 2 +- .../work_order/update_service_report.dart | 2 +- .../work_order/work_order_details_page.dart | 2 +- .../work_order/work_orders_list_page.dart | 2 +- .../widgets/buttons/app_back_button.dart | 2 +- lib/views/widgets/buttons/app_button.dart | 2 +- .../widgets/buttons/app_flat_button.dart | 2 +- .../widgets/buttons/app_icon_button.dart | 2 +- .../widgets/buttons/app_icon_button2.dart | 2 +- .../widgets/buttons/app_outlined_button.dart | 2 +- .../widgets/buttons/app_small_button.dart | 2 +- .../widgets/buttons/rounded_back_button.dart | 2 +- .../widgets/date_and_time/date_picker.dart | 65 +-- .../date_and_time/from_to_date_bar.dart | 2 +- .../widgets/date_and_time/time_picker.dart | 4 +- .../departments/department_button.dart | 2 +- .../widgets/departments/department_item.dart | 2 +- .../device_transfer_info_section.dart | 2 +- .../device_trancfer/device_transfer_item.dart | 2 +- .../device_trancfer/device_transfer_list.dart | 2 +- lib/views/widgets/dialogs/dialog.dart | 2 +- lib/views/widgets/drawer/drawer_item.dart | 2 +- .../widgets/e_signature/e_signature.dart | 2 +- .../widgets/equipment/asset_detail_page.dart | 2 +- .../equipment/asset_item_gridview.dart | 2 +- .../equipment/asset_item_listview.dart | 2 +- lib/views/widgets/equipment/asset_picker.dart | 2 +- .../auto_complete_devices_field.dart | 2 +- .../equipment/auto_complete_models_field.dart | 2 +- .../commissioning_status_buttons.dart | 4 +- .../equipment/single_device_picker.dart | 2 +- .../gas_refill/building_type_menu.dart | 2 +- .../gas_refill/department_type_menu.dart | 2 +- .../widgets/gas_refill/floor_type_menu.dart | 2 +- .../gas_refill_create_details_item.dart | 2 +- .../widgets/gas_refill/gas_refill_item.dart | 2 +- .../widgets/gas_refill/gas_refill_list.dart | 2 +- .../gas_refill_update_details_item.dart | 2 +- .../hospital_auto_complete_field.dart | 2 +- .../hospital_auto_complete_field_new.dart | 2 +- .../widgets/hospitals/hospital_button.dart | 2 +- .../widgets/hospitals/hospital_item.dart | 2 +- lib/views/widgets/images/files_list.dart | 2 +- lib/views/widgets/images/image_item.dart | 2 +- lib/views/widgets/images/images_list.dart | 2 +- lib/views/widgets/images/images_viewer.dart | 2 +- .../widgets/images/mini_one_file_picker.dart | 2 +- .../widgets/images/multi_image_picker.dart | 2 +- .../images/multi_image_picker_item.dart | 2 +- .../widgets/images/one_image_picker.dart | 2 +- lib/views/widgets/input_widget.dart | 2 +- .../widgets/issues/report_issue_item.dart | 2 +- .../widgets/land_page/land_page_item.dart | 2 +- lib/views/widgets/loaders/app_loading.dart | 2 +- lib/views/widgets/loaders/failed_loading.dart | 2 +- lib/views/widgets/loaders/image_loader.dart | 2 +- lib/views/widgets/loaders/lazy_loading.dart | 12 +- lib/views/widgets/loaders/no_item_found.dart | 2 +- .../notifications/notification_item.dart | 2 +- .../parts/auto_complete_parts_field.dart | 2 +- lib/views/widgets/parts/part_item.dart | 2 +- .../auto_complete_devices_field.dart | 2 +- .../pentry/calibration_tool_asset_picker.dart | 2 +- .../pentry/pentry_calibration_tool_form.dart | 2 +- .../widgets/pentry/pentry_pm_kit_form.dart | 2 +- .../pentry/pentry_ppm_check_list_form.dart | 2 +- lib/views/widgets/pentry/pentry_tbs_form.dart | 2 +- lib/views/widgets/ppm/ppm_item.dart | 2 +- lib/views/widgets/qr/asset_scan_qr.dart | 12 +- lib/views/widgets/qr/scan_qr.dart | 2 +- lib/views/widgets/requests/info_row.dart | 2 +- .../widgets/requests/request_status.dart | 8 +- .../requests/service_request_item.dart | 2 +- .../requests/service_request_list.dart | 2 +- .../service_request_update_dialog.dart | 2 +- .../search/asset_transfer_search_dialog.dart | 2 +- lib/views/widgets/search/filter_item.dart | 2 +- lib/views/widgets/search/ppm_search_bar.dart | 2 +- .../search/service_request_search_bar.dart | 2 +- .../widgets/sound/TextSpeechRecordWidget.dart | 44 +- lib/views/widgets/sound/sound_player.dart | 12 +- .../speech_to_text/speech_to_text.dart | 312 ++++++------- lib/views/widgets/status/asset_status.dart | 2 +- .../status/employee/assigned_to_menu.dart | 2 +- .../status/employee/engineers_menu.dart | 2 +- .../status/employee/single_type_menu.dart | 2 +- .../status/gas_refill/gas_cylinder_size.dart | 2 +- .../status/gas_refill/gas_cylinder_type.dart | 2 +- .../widgets/status/gas_refill/gas_status.dart | 2 +- .../widgets/status/gas_refill/gas_type.dart | 2 +- .../widgets/status/multi_status_menu.dart | 2 +- .../status/pentry/pentry_status_mune.dart | 2 +- .../pentry/pentry_task_status_mune.dart | 2 +- .../pentry/pentry_visit_status_mune.dart | 2 +- .../status/report/fault_desc_menu.dart | 2 +- .../report/service_report_all_users.dart | 2 +- ...ervice_report_assistant_employee_menu.dart | 2 +- .../service_report_equipment_status.dart | 2 +- .../service_report_fault_description.dart | 2 +- .../report/service_report_last_call.dart | 36 +- .../service_report_maintenance_situation.dart | 8 +- .../status/report/service_report_reasons.dart | 2 +- .../service_report_repair_location.dart | 31 +- .../status/report/service_report_status.dart | 2 +- .../status/report/service_report_type.dart | 2 +- .../service_report_visit_date_operator.dart | 2 +- .../widgets/status/report/service_status.dart | 2 +- .../service_request_defect_types_mune.dart | 2 +- .../service_request_first_action.dart | 2 +- .../service_request_loan_availability.dart | 2 +- .../service_request_priority_mune.dart | 2 +- .../service_request_status_mune.dart | 2 +- .../service_request_through_mune.dart | 2 +- .../service_request_types_mune.dart | 2 +- .../supplier_engineers_menu.dart | 2 +- .../widgets/status/single_status_menu.dart | 106 ++--- lib/views/widgets/status/users_menu.dart | 2 +- lib/views/widgets/switch_button.dart | 8 +- lib/views/widgets/titles/app_sub_title.dart | 2 +- lib/views/widgets/titles/app_title.dart | 2 +- .../widgets/titles/expandable_info_row.dart | 2 +- pubspec.lock | 80 ++-- pubspec.yaml | 4 +- 263 files changed, 2984 insertions(+), 3176 deletions(-) diff --git a/lib/controllers/api_routes/api_manager.dart b/lib/controllers/api_routes/api_manager.dart index e8464923..0eabcaf5 100644 --- a/lib/controllers/api_routes/api_manager.dart +++ b/lib/controllers/api_routes/api_manager.dart @@ -19,20 +19,16 @@ class ApiManager { Map get _headers => { 'Content-Type': 'application/json', - if (user != null) 'Authorization': 'Bearer ${user.token}', - if (assetGroup != null) 'AssetGroup': assetGroup.id.toString(), + if (user != null) 'Authorization': 'Bearer ${user!.token}', + if (assetGroup != null) 'AssetGroup': assetGroup!.id.toString(), }; static ApiManager instance = ApiManager._(); - User user; - AssetGroup assetGroup; + User? user; + AssetGroup? assetGroup; - Future get( - String url, { - Map headers, - enableToastMessage = true, - }) async { + Future get(String url, {Map? headers, bool enableToastMessage = true}) async { headers ??= {}; headers.addAll(_headers); Uri _url = Uri.parse(url); @@ -54,11 +50,7 @@ class ApiManager { return response; } - Future post( - String url, { - Map headers, - @required Map body, - }) async { + Future post(String url, {Map? headers, required Map body}) async { headers ??= {}; headers.addAll(_headers); @@ -92,11 +84,7 @@ class ApiManager { return response; } - Future put( - String url, { - Map headers, - @required Map body, - }) async { + Future put(String url, {Map? headers, required Map body}) async { headers ??= {}; headers.addAll(_headers); @@ -126,12 +114,7 @@ class ApiManager { return response; } - Future multiPart( - String url, { - Map headers, - @required Map body, - @required List> files, - }) async { + Future multiPart(String url, {Map? headers, required Map body, required List> files}) async { Map _headers = const { 'Content-Type': 'multipart/form-data', }; @@ -173,7 +156,7 @@ class ApiManager { void showLoginDialog() { showDialog( - context: navigatorKey.currentContext, + context: navigatorKey.currentContext!, barrierDismissible: false, builder: (_) => Platform.isIOS ? CupertinoAlertDialog( diff --git a/lib/controllers/notification/firebase_notification_manger.dart b/lib/controllers/notification/firebase_notification_manger.dart index 7649388e..3076b21d 100644 --- a/lib/controllers/notification/firebase_notification_manger.dart +++ b/lib/controllers/notification/firebase_notification_manger.dart @@ -20,16 +20,8 @@ class FirebaseNotificationManger { static FirebaseMessaging messaging = FirebaseMessaging.instance; static String? token; - static Future getToken() async { - NotificationSettings settings = await messaging.requestPermission( - alert: true, - announcement: false, - badge: true, - carPlay: false, - criticalAlert: false, - provisional: false, - sound: true, - ); + static Future getToken() async { + NotificationSettings settings = await messaging.requestPermission(alert: true, announcement: false, badge: true, carPlay: false, criticalAlert: false, provisional: false, sound: true); if (settings.authorizationStatus == AuthorizationStatus.authorized) { try { @@ -98,7 +90,7 @@ class FirebaseNotificationManger { FirebaseMessaging.instance.getInitialMessage().then((initialMessage) { if (initialMessage != null) { - handleMessage(context, initialMessage.data); + handleMessage(context, initialMessage!.data); } }); diff --git a/lib/controllers/notification/notification_manger.dart b/lib/controllers/notification/notification_manger.dart index a52d3e38..7549f23d 100644 --- a/lib/controllers/notification/notification_manger.dart +++ b/lib/controllers/notification/notification_manger.dart @@ -9,32 +9,28 @@ class NotificationManger { // private constructor to avoid create object NotificationManger._(); - static late FlutterLocalNotificationsPlugin localNotificationsPlugin; //= FlutterLocalNotificationsPlugin(); + static late FlutterLocalNotificationsPlugin localNotificationsPlugin; /// initialisation setting for all platform /// onNotificationPressed action when notification pressed to open tap /// onIOSNotificationPressed action when notification pressed /// to open tap in iOS versions older than 10 - Future requestPermissions() async { - - } - static initialisation(Function(NotificationResponse) onNotificationPressed, DidReceiveLocalNotificationCallback onIOSNotificationPressed) async { - FlutterLocalNotificationsPlugin _flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin(); + static Future initialisation(Function(NotificationResponse) onNotificationPressed, DidReceiveLocalNotificationCallback onIOSNotificationPressed) async { + final FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin(); // initialise the plugin. app_icon needs to be a added as a drawable resource to the Android head project const AndroidInitializationSettings initializationSettingsAndroid = AndroidInitializationSettings('@drawable/ic_stat_name'); final DarwinInitializationSettings initializationSettingsDarwin = DarwinInitializationSettings(onDidReceiveLocalNotification: onIOSNotificationPressed); final InitializationSettings initializationSettings = InitializationSettings(android: initializationSettingsAndroid, iOS: initializationSettingsDarwin, macOS: initializationSettingsDarwin); - localNotificationsPlugin = _flutterLocalNotificationsPlugin; + localNotificationsPlugin = flutterLocalNotificationsPlugin; if (Platform.isIOS) { await localNotificationsPlugin.resolvePlatformSpecificImplementation()?.requestPermissions(alert: true, badge: true, sound: true); } else if (Platform.isAndroid) { - AndroidFlutterLocalNotificationsPlugin? androidImplementation = localNotificationsPlugin.resolvePlatformSpecificImplementation(); - bool? granted = await androidImplementation?.requestPermission(); - granted = granted ?? false; - if (granted == false) { + final AndroidFlutterLocalNotificationsPlugin? androidImplementation = localNotificationsPlugin.resolvePlatformSpecificImplementation(); + final bool granted = await androidImplementation?.requestPermission() ?? false; + if (!granted) { if (kDebugMode) { print("-------------------- Permission Granted ------------------------"); print(granted); @@ -44,13 +40,9 @@ class NotificationManger { } await localNotificationsPlugin.initialize(initializationSettings, onDidReceiveNotificationResponse: onNotificationPressed); - //localNotificationsPlugin = flutterLocalNotificationsPlugin; - } - - + } // push new notification - // push new notificationBuildContext - static Future showNotification({@required context, required String title, required String subtext, required int hashcode, String? payload}) async { + static Future showNotification({required BuildContext context, required String title, required String subtext, required int hashcode, String? payload}) async { const AndroidNotificationDetails androidChannel = AndroidNotificationDetails( 'com.hmg.atoms', 'ATOMS', @@ -60,11 +52,7 @@ class NotificationManger { icon: "@drawable/ic_stat_name", playSound: true, channelShowBadge: true, - // enableLights: false, visibility: NotificationVisibility.public, - //ledColor: Theme.of(context).colorScheme.secondary, - // ledOnMs: 1, - // ledOffMs: 0, enableVibration: true, groupKey: 'com.hmg.atoms', ); @@ -73,7 +61,7 @@ class NotificationManger { categoryIdentifier: "atoms", ); - const platformChannel = NotificationDetails(android: androidChannel, iOS: iosNotificationDetails, macOS: iosNotificationDetails); + const NotificationDetails platformChannel = NotificationDetails(android: androidChannel, iOS: iosNotificationDetails, macOS: iosNotificationDetails); await localNotificationsPlugin.show(hashcode, title, subtext, platformChannel, payload: payload); } diff --git a/lib/controllers/providers/api/all_requests_provider.dart b/lib/controllers/providers/api/all_requests_provider.dart index e7f58c52..168e2231 100644 --- a/lib/controllers/providers/api/all_requests_provider.dart +++ b/lib/controllers/providers/api/all_requests_provider.dart @@ -1,5 +1,4 @@ import 'dart:convert'; -import 'dart:developer'; import 'package:flutter/widgets.dart'; import 'package:http/http.dart'; @@ -21,8 +20,7 @@ class AllRequestsProvider extends ChangeNotifier { bool _isFilterRequestLoading = false; bool _isRequestCategoryLoading = false; - int _status =0; - + int _status = 0; int get status => _status; @@ -40,23 +38,28 @@ class AllRequestsProvider extends ChangeNotifier { notifyListeners(); } - int stateCode; + int? stateCode; - AllRequestsAndCount allRequestsAndCount; - AllRequestsAndCount _openRequests; - AllRequestsAndCount _inProgressRequests; - AllRequestsAndCount _completedRequests; - AllRequestsAndCount _filterRequest; - AllRequestsAndCount _requestDetailList; + AllRequestsAndCount? _allRequestsAndCount; + AllRequestsAndCount? _openRequests; + AllRequestsAndCount? _inProgressRequests; + AllRequestsAndCount? _completedRequests; + AllRequestsAndCount? _filterRequest; + AllRequestsAndCount? _requestDetailList; - AllRequestsAndCount get requestDetailList => _requestDetailList; + AllRequestsAndCount? get allRequestsAndCount => _allRequestsAndCount; + AllRequestsAndCount? get highPriorityRequests => _highPriorityRequests; + AllRequestsAndCount? get overdueRequests => _overdueRequests; + AllRequestsAndCount? get openRequests => _openRequests; + AllRequestsAndCount? get completedRequests => _completedRequests; + AllRequestsAndCount? get requestDetailList => _requestDetailList; - set requestDetailList(AllRequestsAndCount value) { + set requestDetailList(AllRequestsAndCount? value) { _requestDetailList = value; notifyListeners(); } - AllRequestsAndCount _selectedRequestCategory; + AllRequestsAndCount? _selectedRequestCategory; bool get isRequestCategoryLoading => _isRequestCategoryLoading; @@ -64,8 +67,9 @@ class AllRequestsProvider extends ChangeNotifier { _isRequestCategoryLoading = value; notifyListeners(); } // overdue,high priority, new , completed - AllRequestsAndCount overdueRequests; - AllRequestsAndCount highPriorityRequests; + + AllRequestsAndCount? _overdueRequests; + AllRequestsAndCount? _highPriorityRequests; bool isLoadingList = false; @@ -74,15 +78,15 @@ class AllRequestsProvider extends ChangeNotifier { notifyListeners(); } - AllRequestsAndCount calendarRequests; + AllRequestsAndCount? calendarRequests; final pageItemNumber = 10; int pageNum = 1; bool nextPage = true; void reset() { - allRequestsAndCount?.requestsDetails?.clear(); - allRequestsAndCount = null; + _allRequestsAndCount?.requestsDetails?.clear(); + _allRequestsAndCount = null; pageNum = 1; nextPage = true; stateCode = null; @@ -90,8 +94,8 @@ class AllRequestsProvider extends ChangeNotifier { void resetRequestsApiData() { print('reset api data called..'); - highPriorityRequests = null; - overdueRequests = null; + _highPriorityRequests = null; + _overdueRequests = null; openRequests = null; inProgressRequests = null; completedRequests = null; @@ -100,21 +104,21 @@ class AllRequestsProvider extends ChangeNotifier { stateCode = null; } - Future getRequests() { + Future getRequests() async { resetRequestsApiData(); - getOpenRequests(pagination: true); - getInProgressRequests(pagination: true); - getCompletedRequests(pagination: true); + getOpenRequests(pagination: true); + getInProgressRequests(pagination: true); + getCompletedRequests(pagination: true); getHighPriorityRequests(pagination: true); getOverdueRequests(pagination: true); } - SearchAllRequestsModel searchedModel; + SearchAllRequestsModel? searchedModel; - Future getAllRequests(BuildContext context, {int typeTransaction, SearchAllRequestsModel search}) async { + Future getAllRequests(BuildContext context, {int? typeTransaction, SearchAllRequestsModel? search}) async { if (isAllLoading == true) return -2; isAllLoading = true; - if (allRequestsAndCount == null) notifyListeners(); + if (_allRequestsAndCount == null) notifyListeners(); Response response; try { if (search != null) { @@ -123,11 +127,11 @@ class AllRequestsProvider extends ChangeNotifier { searchedModel = null; } final type = typeTransaction == null - ? search?.typeTransaction == null || search.typeTransaction.isEmpty + ? search?.typeTransaction == null || (search?.typeTransaction?.isEmpty ?? false) ? [1, 2, 3, 4] - : search.typeTransaction + : search!.typeTransaction : [typeTransaction]; - List status = (search?.statuses == null || search.statuses.isEmpty) ? ((search?.isArchived ?? false) ? [3] : [1, 2, 4]) : search.statuses; + List status = (search?.statuses == null || (search?.statuses?.isEmpty ?? false)) ? (((search?.isArchived ?? false) ? [3] : [1, 2, 4])) : search!.statuses!; Map body = { "typeTransaction": type, "statusTransaction": status, @@ -135,32 +139,32 @@ class AllRequestsProvider extends ChangeNotifier { "displayData": [], "pageNumber": pageNum++, "pageSize": pageItemNumber, - if (search?.requestNumber?.value?.isNotEmpty ?? false) "requestNumber": search.requestNumber.value, - if (search?.assetName?.value?.isNotEmpty ?? false) "assetName": search.assetName.value, - if (search?.assetNo?.value?.isNotEmpty ?? false) "assetNumber": search.assetNo.value, - if (search?.sn?.value?.isNotEmpty ?? false) "assetSerialNo": search.sn.value, - if (search?.model?.value?.isNotEmpty ?? false) "model": search.model.value, - if (search?.manufacture?.value?.isNotEmpty ?? false) "manufacturer": search.manufacture.value, - if (search?.startDate != null) "from": search.startDate.toIso8601String(), - if (search?.endDate != null) "to": search.endDate.toIso8601String(), + if (search?.requestNumber?.value?.isNotEmpty ?? false) "requestNumber": search!.requestNumber!.value, + if (search?.assetName?.value?.isNotEmpty ?? false) "assetName": search!.assetName!.value, + if (search?.assetNo?.value?.isNotEmpty ?? false) "assetNumber": search!.assetNo!.value, + if (search?.sn?.value?.isNotEmpty ?? false) "assetSerialNo": search!.sn!.value, + if (search?.model?.value?.isNotEmpty ?? false) "model": search!.model!.value, + if (search?.manufacture?.value?.isNotEmpty ?? false) "manufacturer": search!.manufacture!.value, + if (search?.startDate != null) "from": search!.startDate!.toIso8601String(), + if (search?.endDate != null) "to": search!.endDate!.toIso8601String(), }; response = await ApiManager.instance.post(URLs.getAllRequestsAndCount, body: body); stateCode = response.statusCode; if (response.statusCode >= 200 && response.statusCode < 300) { - if (allRequestsAndCount == null) { - allRequestsAndCount = AllRequestsAndCount.fromJson(json.decode(response.body)["data"][0]); + if (_allRequestsAndCount == null) { + _allRequestsAndCount = AllRequestsAndCount.fromJson(json.decode(response.body)["data"][0]); } else { - allRequestsAndCount.requestsDetails.addAll(AllRequestsAndCount.fromJson(json.decode(response.body)["data"][0]).requestsDetails); + _allRequestsAndCount!.requestsDetails!.addAll(AllRequestsAndCount.fromJson(json.decode(response.body)["data"][0]).requestsDetails!); } - if (allRequestsAndCount.requestsDetails.length >= pageItemNumber) { + if (_allRequestsAndCount!.requestsDetails!.length >= pageItemNumber) { nextPage = true; } else { nextPage = false; } notifyListeners(); } else { - allRequestsAndCount = null; + _allRequestsAndCount = null; } isAllLoading = false; notifyListeners(); @@ -173,7 +177,7 @@ class AllRequestsProvider extends ChangeNotifier { } } - Future getCalendarRequests({@required DateTime from, DateTime to}) async { + Future getCalendarRequests({required DateTime from, DateTime? to}) async { if (isCalendarLoading == true) return -2; isCalendarLoading = true; notifyListeners(); @@ -209,7 +213,7 @@ class AllRequestsProvider extends ChangeNotifier { Future getHighPriorityRequests({bool pagination = false}) async { if (isHighPriorityLoading == true) return -2; - if (highPriorityRequests == null || pagination) { + if (_highPriorityRequests == null || pagination) { isHighPriorityLoading = true; // notifyListeners(); } @@ -231,12 +235,12 @@ class AllRequestsProvider extends ChangeNotifier { response = await ApiManager.instance.post(URLs.getAllRequestsAndCount, body: body); stateCode = response.statusCode; if (response.statusCode >= 200 && response.statusCode < 300) { - if (highPriorityRequests == null) { - highPriorityRequests = AllRequestsAndCount.fromJson(json.decode(response.body)["data"][0]); + if (_highPriorityRequests == null) { + _highPriorityRequests = AllRequestsAndCount.fromJson(json.decode(response.body)["data"][0]); } else { - highPriorityRequests.requestsDetails.addAll(AllRequestsAndCount.fromJson(json.decode(response.body)["data"][0]).requestsDetails); + _highPriorityRequests!.requestsDetails!.addAll(AllRequestsAndCount.fromJson(json.decode(response.body)["data"][0]).requestsDetails!); } - if (highPriorityRequests.requestsDetails.length >= pageItemNumber) { + if (_highPriorityRequests!.requestsDetails!.length >= pageItemNumber) { nextPage = true; } else { nextPage = false; @@ -244,7 +248,7 @@ class AllRequestsProvider extends ChangeNotifier { notifyListeners(); } else { - allRequestsAndCount = null; + _allRequestsAndCount = null; } isHighPriorityLoading = false; notifyListeners(); @@ -259,7 +263,7 @@ class AllRequestsProvider extends ChangeNotifier { Future getOverdueRequests({bool pagination = false}) async { if (isOverdueLoading == true) return -2; - if (overdueRequests == null || pagination) { + if (_overdueRequests == null || pagination) { isOverdueLoading = true; notifyListeners(); } @@ -282,19 +286,19 @@ class AllRequestsProvider extends ChangeNotifier { stateCode = response.statusCode; if (response.statusCode >= 200 && response.statusCode < 300) { - if (overdueRequests == null) { - overdueRequests = AllRequestsAndCount.fromJson(json.decode(response.body)["data"][0]); + if (_overdueRequests == null) { + _overdueRequests = AllRequestsAndCount.fromJson(json.decode(response.body)["data"][0]); } else { - overdueRequests.requestsDetails.addAll(AllRequestsAndCount.fromJson(json.decode(response.body)["data"][0]).requestsDetails); + _overdueRequests!.requestsDetails!.addAll(AllRequestsAndCount.fromJson(json.decode(response.body)["data"][0]).requestsDetails!); } - if (overdueRequests.requestsDetails.length >= pageItemNumber) { + if (_overdueRequests!.requestsDetails!.length >= pageItemNumber) { nextPage = true; } else { nextPage = false; } notifyListeners(); } else { - allRequestsAndCount = null; + _allRequestsAndCount = null; } isOverdueLoading = false; notifyListeners(); @@ -319,7 +323,7 @@ class AllRequestsProvider extends ChangeNotifier { } Response response; try { - bool isEngineer = ApiManager.instance.user.type == UsersTypes.engineer; + bool isEngineer = ApiManager.instance.user!.type == UsersTypes.engineer; Map body = { "typeTransaction": [1, 2, 3, 4], "statusTransaction": [isEngineer ? 2 : 1], @@ -340,16 +344,16 @@ class AllRequestsProvider extends ChangeNotifier { if (openRequests == null) { openRequests = AllRequestsAndCount.fromJson(json.decode(response.body)["data"][0]); } else { - openRequests.requestsDetails.addAll(AllRequestsAndCount.fromJson(json.decode(response.body)["data"][0]).requestsDetails); + openRequests!.requestsDetails!.addAll(AllRequestsAndCount.fromJson(json.decode(response.body)["data"][0]).requestsDetails!); } - if (openRequests.requestsDetails.length >= pageItemNumber) { + if (openRequests!.requestsDetails!.length >= pageItemNumber) { nextPage = true; } else { nextPage = false; } notifyListeners(); } else { - allRequestsAndCount = null; + _allRequestsAndCount = null; } isOpenLoading = false; notifyListeners(); @@ -363,7 +367,6 @@ class AllRequestsProvider extends ChangeNotifier { } Future getInProgressRequests({bool pagination = false, bool reset = false}) async { - if (isInProgressLoading == true) return -2; if (reset) { inProgressRequests = null; @@ -397,17 +400,17 @@ class AllRequestsProvider extends ChangeNotifier { inProgressRequests = AllRequestsAndCount.fromJson(json.decode(response.body)["data"][0]); notifyListeners(); } else { - inProgressRequests.requestsDetails.addAll(AllRequestsAndCount.fromJson(json.decode(response.body)["data"][0]).requestsDetails); + inProgressRequests!.requestsDetails!.addAll(AllRequestsAndCount.fromJson(json.decode(response.body)["data"][0]).requestsDetails!); notifyListeners(); } - if (inProgressRequests.requestsDetails.length >= pageItemNumber) { + if (inProgressRequests!.requestsDetails!.length >= pageItemNumber) { nextPage = true; } else { nextPage = false; } notifyListeners(); } else { - allRequestsAndCount = null; + _allRequestsAndCount = null; } isInProgressLoading = false; print('value of inProgress loading in provider is $isInProgressLoading'); @@ -421,12 +424,12 @@ class AllRequestsProvider extends ChangeNotifier { } } - Future getFilterRequests({bool showLoader = true, int status}) async { + Future getFilterRequests({bool showLoader = true, required int status}) async { // if (filterRequest == null || pagination) { // isFilterRequestLoading = true; // notifyListeners(); // } - isFilterRequestLoading =showLoader; + isFilterRequestLoading = showLoader; Response response; try { Map body = { @@ -434,8 +437,8 @@ class AllRequestsProvider extends ChangeNotifier { "statusTransaction": [status], "priority": [], "displayData": [], - "pageNumber": pageNum, - "pageSize" : pageItemNumber, + "pageNumber": pageNum, + "pageSize": pageItemNumber, }; response = await ApiManager.instance.post(URLs.getAllRequestsAndCount, body: body); stateCode = response.statusCode; @@ -445,11 +448,11 @@ class AllRequestsProvider extends ChangeNotifier { isFilterRequestLoading = false; notifyListeners(); } else { - filterRequest.requestsDetails.addAll(AllRequestsAndCount.fromJson(json.decode(response.body)["data"][0]).requestsDetails); + filterRequest!.requestsDetails!.addAll(AllRequestsAndCount.fromJson(json.decode(response.body)["data"][0]).requestsDetails!); isFilterRequestLoading = false; notifyListeners(); } - if (filterRequest.requestsDetails.length >= pageItemNumber) { + if (filterRequest!.requestsDetails!.length >= pageItemNumber) { nextPage = true; } else { nextPage = false; @@ -468,8 +471,9 @@ class AllRequestsProvider extends ChangeNotifier { return -1; } } - Future getSelectedRequestCategory({RequestQueryModel requestQueryModel}) async { - isRequestCategoryLoading =requestQueryModel.showLoader; + + Future getSelectedRequestCategory({required RequestQueryModel requestQueryModel}) async { + isRequestCategoryLoading = requestQueryModel.showLoader; Response response; try { response = await ApiManager.instance.post(URLs.getAllRequestsAndCount, body: requestQueryModel.toJson()); @@ -480,7 +484,7 @@ class AllRequestsProvider extends ChangeNotifier { isRequestCategoryLoading = false; notifyListeners(); } else { - selectedRequestCategory.requestsDetails.addAll(AllRequestsAndCount.fromJson(json.decode(response.body)["data"][0]).requestsDetails); + selectedRequestCategory!.requestsDetails!.addAll(AllRequestsAndCount.fromJson(json.decode(response.body)["data"][0]).requestsDetails!); isRequestCategoryLoading = false; notifyListeners(); } @@ -530,17 +534,17 @@ class AllRequestsProvider extends ChangeNotifier { if (completedRequests == null) { completedRequests = AllRequestsAndCount.fromJson(json.decode(response.body)["data"][0]); } else { - completedRequests.requestsDetails.addAll(AllRequestsAndCount.fromJson(json.decode(response.body)["data"][0]).requestsDetails); + completedRequests!.requestsDetails!.addAll(AllRequestsAndCount.fromJson(json.decode(response.body)["data"][0]).requestsDetails!); } - print('completed request length is ${completedRequests.requestsDetails.length}'); - if (completedRequests.requestsDetails.length >= pageItemNumber) { + print('completed request length is ${completedRequests!.requestsDetails!.length}'); + if (completedRequests!.requestsDetails!.length >= pageItemNumber) { nextPage = true; } else { nextPage = false; } notifyListeners(); } else { - allRequestsAndCount = null; + _allRequestsAndCount = null; } isCompleteLoading = false; notifyListeners(); @@ -553,34 +557,34 @@ class AllRequestsProvider extends ChangeNotifier { } } + AllRequestsAndCount? get inProgressRequests => _inProgressRequests; - AllRequestsAndCount get inProgressRequests => _inProgressRequests; - - set inProgressRequests(AllRequestsAndCount value) { + set inProgressRequests(AllRequestsAndCount? value) { _inProgressRequests = value; notifyListeners(); } - AllRequestsAndCount get completedRequests => _completedRequests; + AllRequestsAndCount? get completedRequests => _completedRequests; - set completedRequests(AllRequestsAndCount value) { + set completedRequests(AllRequestsAndCount? value) { _completedRequests = value; notifyListeners(); } - AllRequestsAndCount get openRequests => _openRequests; + AllRequestsAndCount? get openRequests => _openRequests; - set openRequests(AllRequestsAndCount value) { + set openRequests(AllRequestsAndCount? value) { _openRequests = value; notifyListeners(); } - AllRequestsAndCount get filterRequest => _filterRequest; + AllRequestsAndCount? get filterRequest => _filterRequest; - set filterRequest(AllRequestsAndCount value) { + set filterRequest(AllRequestsAndCount? value) { _filterRequest = value; notifyListeners(); } + bool get isFilterRequestLoading => _isFilterRequestLoading; set isFilterRequestLoading(bool value) { @@ -588,9 +592,9 @@ class AllRequestsProvider extends ChangeNotifier { notifyListeners(); } - AllRequestsAndCount get selectedRequestCategory => _selectedRequestCategory; + AllRequestsAndCount? get selectedRequestCategory => _selectedRequestCategory; - set selectedRequestCategory(AllRequestsAndCount value) { + set selectedRequestCategory(AllRequestsAndCount? value) { _selectedRequestCategory = value; notifyListeners(); } diff --git a/lib/controllers/providers/api/gas_refill_provider.dart b/lib/controllers/providers/api/gas_refill_provider.dart index 3077cda2..5249e046 100644 --- a/lib/controllers/providers/api/gas_refill_provider.dart +++ b/lib/controllers/providers/api/gas_refill_provider.dart @@ -163,11 +163,11 @@ class GasRefillProvider extends ChangeNotifier { "comment": newModel.comment, }; - body["gazRefillDetails"] = newModel.gazRefillDetails + body["gazRefillDetails"] = newModel.gazRefillDetails! .map((model) => { - "gasType": model.gasType.toJson(), - "cylinderSize": model.cylinderSize.toJson(), - "cylinderType": model.cylinderType.toJson(), + "gasType": model.gasType?.toJson(), + "cylinderSize": model.cylinderSize?.toJson(), + "cylinderType": model.cylinderType?.toJson(), "requestedQty": model.requestedQty, "deliverdQty": model.deliverdQty, }) diff --git a/lib/controllers/providers/api/ppm_provider.dart b/lib/controllers/providers/api/ppm_provider.dart index e2310270..c37f7745 100644 --- a/lib/controllers/providers/api/ppm_provider.dart +++ b/lib/controllers/providers/api/ppm_provider.dart @@ -171,7 +171,7 @@ class PpmProvider extends ChangeNotifier { required Ppm ppm, }) async { try { - ppm.visitTimers.add( + ppm.visitTimers?.add( VisitTimers( id: 0, startDateTime: ppm.tbsTimer?.startAt!.toIso8601String(), // Handle potential null @@ -179,7 +179,7 @@ class PpmProvider extends ChangeNotifier { workingHours: ((ppm.tbsTimer?.durationInSecond ?? 0) / 60 / 60), ), ); - showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading()); + showDialog(context: context, barrierDismissible: false, builder: (context) => AppLazyLoading()); late Response response; // Using 'late' for initialization later Map body = ppm.copyWith(assignedEmployeeId: user.userName, tbsTimer: ppm.tbsTimer).toJson(); response = await ApiManager.instance.put(URLs.updatePentry, body: body); diff --git a/lib/controllers/providers/api/preventive_maintenance_visits_provider.dart b/lib/controllers/providers/api/preventive_maintenance_visits_provider.dart index 4b890ffe..88f1d300 100644 --- a/lib/controllers/providers/api/preventive_maintenance_visits_provider.dart +++ b/lib/controllers/providers/api/preventive_maintenance_visits_provider.dart @@ -45,8 +45,8 @@ // /// for more details check http state manager // /// lib\controllers\http_status_manger\http_status_manger.dart // Future getVisits({ -// @required String host, -// @required User user, +// required String host, +// required User user, // // VisitsSearch visitsSearch, // }) async { // if (isLoading == true) return -2; @@ -89,8 +89,8 @@ // /// for more details check http state manager // /// lib\controllers\http_status_manger\http_status_manger.dart // Future updateGroupOfVisits({ -// @required String host, -// @required User user, +// required String host, +// required User user, // VisitsGroup group, // }) async { // Response response; diff --git a/lib/controllers/providers/api/service_requests_provider.dart b/lib/controllers/providers/api/service_requests_provider.dart index a51f396a..6e704523 100644 --- a/lib/controllers/providers/api/service_requests_provider.dart +++ b/lib/controllers/providers/api/service_requests_provider.dart @@ -1,5 +1,4 @@ import 'dart:convert'; -import 'dart:developer'; import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; @@ -30,7 +29,6 @@ class ServiceRequestsProvider extends ChangeNotifier { // number of items call in each request final pageItemNumber = 10; - //reset provider data void reset() { workOrders = []; @@ -43,7 +41,7 @@ class ServiceRequestsProvider extends ChangeNotifier { // like 400 customer request failed // 500 service not available int stateCode; - bool _isDetialLoading=false; + bool _isDetialLoading = false; bool get isDetialLoading => _isDetialLoading; @@ -51,8 +49,9 @@ class ServiceRequestsProvider extends ChangeNotifier { _isDetialLoading = value; notifyListeners(); } // true if there is next page in product list and false if not + bool nextPage = true; - TimeOfDay _selectedTime ; + TimeOfDay _selectedTime; TimeOfDay get selectedTime => _selectedTime; @@ -60,12 +59,11 @@ class ServiceRequestsProvider extends ChangeNotifier { _selectedTime = value; notifyListeners(); } // list of user requests + List serviceRequests; List workOrders = []; List _sparePartList = []; - - SparePartsWorkOrders _initialSelectedSparePart = SparePartsWorkOrders(); ServiceRequest _currentSelectedRequest; int _selectedListIndex = 0; @@ -96,7 +94,7 @@ class ServiceRequestsProvider extends ChangeNotifier { /// return state code if request complete may be 200, 404 or 403 /// for more details check http state manager /// lib\controllers\http_status_manger\http_status_manger.dart - Future getRequests({@required int hospitalId}) async { + Future getRequests({required int hospitalId}) async { if (isLoading == true) return -2; isLoading = true; if (serviceRequests?.isEmpty ?? false) notifyListeners(); @@ -138,10 +136,10 @@ class ServiceRequestsProvider extends ChangeNotifier { } Future getSingleServiceRequest({ - @required String requestId, - @required String host, - @required User user, - @required AppLocalizations subtitle, + required String requestId, + required String host, + required User user, + required AppLocalizations subtitle, }) async { String userData = ''; if (user != null) { @@ -173,10 +171,10 @@ class ServiceRequestsProvider extends ChangeNotifier { } Future createRequest({ - @required BuildContext context, - @required String host, - @required User user, - @required ServiceRequest serviceRequest, + required BuildContext context, + required String host, + required User user, + required ServiceRequest serviceRequest, }) async { var body = { "id": 0, @@ -284,7 +282,7 @@ class ServiceRequestsProvider extends ChangeNotifier { } } - Future updateRequest({@required User user, @required ServiceRequest request}) async { + Future updateRequest({required User user, required ServiceRequest request}) async { isLoading = true; notifyListeners(); Map serviceRequest = await getServiceRequestById(requestId: request.id) ?? ""; @@ -368,7 +366,7 @@ class ServiceRequestsProvider extends ChangeNotifier { } } - Future createServiceReport(BuildContext context, {@required ServiceReport report, @required User user, @required ServiceRequest request}) async { + Future createServiceReport(BuildContext context, {required ServiceReport report, required User user, required ServiceRequest request}) async { Response response; try { showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading()); @@ -407,7 +405,7 @@ class ServiceRequestsProvider extends ChangeNotifier { } } - Future createSubWorkOrder({@required SearchWorkOrder workOrder, bool makeSuppPersonsEmpty = false}) async { + Future createSubWorkOrder({required SearchWorkOrder workOrder, bool makeSuppPersonsEmpty = false}) async { Response response; try { if (makeSuppPersonsEmpty) workOrder.supplier?.suppPersons = []; @@ -427,7 +425,7 @@ class ServiceRequestsProvider extends ChangeNotifier { CallRequest callRequestForWorkOrder; - Future getCallRequestForWorkOrder({String callId}) async { + Future getCallRequestForWorkOrder({String? callId}) async { Response response; try { response = await ApiManager.instance.get( @@ -437,7 +435,7 @@ class ServiceRequestsProvider extends ChangeNotifier { if (response.statusCode >= 200 && response.statusCode < 300) { // client's request was successfully received Map listJson = json.decode(response.body)["data"]; - log(listJson?.toString()); + // log(listJson?.toString()); callRequestForWorkOrder = CallRequest.fromJson(listJson); } @@ -449,7 +447,7 @@ class ServiceRequestsProvider extends ChangeNotifier { } } - Future> searchWorkOrders({@required String callId}) async { + Future> searchWorkOrders({required String callId}) async { Response response; try { @@ -476,7 +474,7 @@ class ServiceRequestsProvider extends ChangeNotifier { } } - Future getSubWorkOrderDetails({@required String parentId}) async { + Future getSubWorkOrderDetails({required String parentId}) async { Response response; try { response = await ApiManager.instance.get(URLs.getSubWorkerInfoAccordingToPreviousStep + "?parentId=$parentId"); @@ -494,9 +492,9 @@ class ServiceRequestsProvider extends ChangeNotifier { } Future createDuplicatedReport({ - @required String host, - @required User user, - @required ServiceRequest request, + required String host, + required User user, + required ServiceRequest request, }) async { Response response; String userData = ''; @@ -522,7 +520,7 @@ class ServiceRequestsProvider extends ChangeNotifier { } } - Future updateServiceReport(BuildContext context, {@required ServiceReport report}) async { + Future updateServiceReport(BuildContext context, {required ServiceReport report}) async { Response response; report.callRequest = CallRequest(id: report.callRequest.id); Map body = report.toJson(); @@ -546,7 +544,7 @@ class ServiceRequestsProvider extends ChangeNotifier { } } - Future updateWorkOrderDetails({@required SearchWorkOrder workOrder}) async { + Future updateWorkOrderDetails({required SearchWorkOrder workOrder}) async { Response response; //Map body = report.toMap(request); // body["uid"] = user.id; @@ -576,10 +574,10 @@ class ServiceRequestsProvider extends ChangeNotifier { } Future updateServiceReportTimer({ - @required String host, - @required User user, - @required TimerModel timer, - @required ServiceRequest request, + required String host, + required User user, + required TimerModel timer, + required ServiceRequest request, }) async { Response response; Map body = {}; @@ -607,7 +605,7 @@ class ServiceRequestsProvider extends ChangeNotifier { } } - Future getSingleServiceReport(BuildContext context, {@required int reportId}) async { + Future getSingleServiceReport(BuildContext context, {required int reportId}) async { Response response; try { response = await ApiManager.instance.get(URLs.getServiceReport + "?workOrderId=$reportId"); @@ -624,24 +622,24 @@ class ServiceRequestsProvider extends ChangeNotifier { } } - Future getServiceRequestObjectById({@required String requestId}) async { + Future getServiceRequestObjectById({required String requestId}) async { try { isDetialLoading = true; Response response = await ApiManager.instance.get(URLs.getServiceRequestById + "?callRequestId=$requestId"); if (response.statusCode >= 200 && response.statusCode < 300) { - isDetialLoading=false; + isDetialLoading = false; return ServiceRequest.fromJson(json.decode(response.body)["data"]); } else { - isDetialLoading=false; + isDetialLoading = false; return null; } } catch (error) { - isDetialLoading=false; + isDetialLoading = false; return null; } } - Future> getServiceRequestById({@required String requestId}) async { + Future> getServiceRequestById({required String requestId}) async { Response response; try { response = await ApiManager.instance.get( @@ -739,6 +737,7 @@ class ServiceRequestsProvider extends ChangeNotifier { _initialSelectedSparePart = value; notifyListeners(); } + List get sparePartList => _sparePartList; set sparePartList(List value) { diff --git a/lib/controllers/providers/api/status_drop_down/report/service_report_assistants_employee_provider.dart b/lib/controllers/providers/api/status_drop_down/report/service_report_assistants_employee_provider.dart index 510ab11f..2b3f2a48 100644 --- a/lib/controllers/providers/api/status_drop_down/report/service_report_assistants_employee_provider.dart +++ b/lib/controllers/providers/api/status_drop_down/report/service_report_assistants_employee_provider.dart @@ -1,9 +1,7 @@ import 'dart:convert'; -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:http/http.dart'; -import 'package:test_sa/controllers/api_routes/api_manager.dart'; +import 'package:http/http.dart';import 'package:test_sa/controllers/api_routes/api_manager.dart'; import 'package:test_sa/controllers/api_routes/urls.dart'; import 'package:test_sa/models/employee.dart'; @@ -14,29 +12,29 @@ class ServiceReportAssistantsEmployeeProvider extends ChangeNotifier { //reset provider data void reset() { _assistantEmployees = null; - _loading = null; + _loading = false; // Set to false initially _stateCode = null; } // state code of current request to defied error message // like 400 customer request failed // 500 service not available - int _stateCode; + int? _stateCode; - int get stateCode => _stateCode; + int? get stateCode => _stateCode; - set setStateCode(int statusCode) => _stateCode = statusCode; + set stateCode(int? statusCode) => _stateCode = statusCode; // contain user data // when user not login or register _user = null - List _assistantEmployees; + List? _assistantEmployees; - List get assistantEmployees => _assistantEmployees; + List? get assistantEmployees => _assistantEmployees; // when categories in-process _loading = true // done _loading = true // failed _loading = false - bool _loading; + bool _loading = false; // Initialize to false bool get isLoading => _loading; @@ -51,29 +49,22 @@ class ServiceReportAssistantsEmployeeProvider extends ChangeNotifier { /// for more details check http state manager /// lib\controllers\http_status_manger\http_status_manger.dart Future getAssistantEmployees(num assetId) async { - if (_loading == true) return -2; + if (_loading) return -2; _loading = true; notifyListeners(); - Response response; - try { - response = await ApiManager.instance.get("${URLs.getEngineers}&assetId=$assetId"); - // response = await get( - // Uri.parse( - // URLs.getServiceReportLastCalls - // +(serviceStatus == null ? "" : "?service_status=$serviceStatus") - // ), - // ); - _stateCode = response.statusCode; - if (response.statusCode >= 200 && response.statusCode < 300) { - // client's request was successfully received - List usersListJson = json.decode(response.body); - _assistantEmployees = []; - _assistantEmployees = usersListJson.map((type) => Employee.fromJson(type ?? {})).map((e) => AssistantEmployees(user: AssignedEmployee(id: e.id, name: e.name))).toList(); - _assistantEmployees.insert(0, AssistantEmployees(id: -1, user: AssignedEmployee(id: "-1", name: "-- Select --"))); - } - _loading = false; - notifyListeners(); - return response.statusCode; + try {final response = await ApiManager.instance.get("${URLs.getEngineers}&assetId=$assetId"); + _stateCode = response.statusCode; + if (response.statusCode >= 200 && response.statusCode < 300) { + final usersListJson = json.decode(response.body) as List; + _assistantEmployees = usersListJson + .map((type) => Employee.fromJson(type)) + .map((e) => AssistantEmployees(user: AssignedEmployee(id: e.id, name: e.name))) + .toList(); + _assistantEmployees?.insert(0, AssistantEmployees(id: -1, user: AssignedEmployee(id: "-1", name: "-- Select --"))); + } + _loading = false; + notifyListeners(); + return response.statusCode; } catch (error) { _loading = false; _stateCode = -1; @@ -81,4 +72,4 @@ class ServiceReportAssistantsEmployeeProvider extends ChangeNotifier { return -1; } } -} +} \ No newline at end of file diff --git a/lib/controllers/providers/api/status_drop_down/report/service_report_last_calls_provider.dart b/lib/controllers/providers/api/status_drop_down/report/service_report_last_calls_provider.dart index c8377fee..43c1c4d8 100644 --- a/lib/controllers/providers/api/status_drop_down/report/service_report_last_calls_provider.dart +++ b/lib/controllers/providers/api/status_drop_down/report/service_report_last_calls_provider.dart @@ -1,8 +1,6 @@ import 'dart:convert'; -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:http/http.dart'; import 'package:test_sa/controllers/api_routes/api_manager.dart'; import 'package:test_sa/controllers/api_routes/urls.dart'; import 'package:test_sa/models/lookup.dart'; @@ -11,27 +9,19 @@ class ServiceReportLastCallsProvider extends ChangeNotifier { //reset provider data void reset() { _calls = null; - _loading = null; + _loading = false; // Set to false initially _stateCode = null; } - // state code of current request to defied error message - // like 400 customer request failed - // 500 service not available - int _stateCode; + int? _stateCode; - int get stateCode => _stateCode; + int? get stateCode => _stateCode; - // contain user data - // when user not login or register _user = null - List _calls; + List? _calls; - List get calls => _calls; + List? get calls => _calls; - // when categories in-process _loading = true - // done _loading = true - // failed _loading = false - bool _loading; + bool _loading = false; // Initialize to false bool get isLoading => _loading; @@ -40,24 +30,17 @@ class ServiceReportLastCallsProvider extends ChangeNotifier { notifyListeners(); } - /// return -2 if request in progress - /// return -1 if error happen when sending request - /// return state code if request complete may be 200, 404 or 403 - /// for more details check http state manager - /// lib\controllers\http_status_manger\http_status_manger.dart - Future getCalls({String parentId, int id, String typeName}) async { - if (_loading == true) return -2; + Future getCalls({String? parentId, int? id, String? typeName}) async { + if (_loading) return -2; _loading = true; notifyListeners(); - Response response; try { - response = await ApiManager.instance.get( + final response = await ApiManager.instance.get( "${URLs.getServiceReportLastCalls}?parentWOId=${parentId ?? id}&isAdd=true&id=${id ?? 0}&typeTransaction=$typeName", ); _stateCode = response.statusCode; if (response.statusCode >= 200 && response.statusCode < 300) { - // client's request was successfully received - List categoriesListJson = json.decode(response.body)["data"]; + final categoriesListJson = json.decode(response.body)["data"] as List; _calls = categoriesListJson.map((type) => Lookup.fromJson(type)).toList(); } _loading = false; diff --git a/lib/controllers/providers/api/status_drop_down/report/service_report_repair_location_provider.dart b/lib/controllers/providers/api/status_drop_down/report/service_report_repair_location_provider.dart index f9b38f3c..d80099bb 100644 --- a/lib/controllers/providers/api/status_drop_down/report/service_report_repair_location_provider.dart +++ b/lib/controllers/providers/api/status_drop_down/report/service_report_repair_location_provider.dart @@ -18,20 +18,20 @@ class ServiceReportRepairLocationProvider extends ChangeNotifier { // state code of current request to defied error message // like 400 customer request failed // 500 service not available - int _stateCode; + int? _stateCode; - int get stateCode => _stateCode; + int? get stateCode => _stateCode; // contain user data // when user not login or register _user = null - List _reasons; + List? _reasons; - List get reasons => _reasons; + List? get reasons => _reasons; // when categories in-process _loading = true // done _loading = true // failed _loading = false - bool _loading; + bool _loading = false; bool get isLoading => _loading; @@ -45,7 +45,7 @@ class ServiceReportRepairLocationProvider extends ChangeNotifier { /// return state code if request complete may be 200, 404 or 403 /// for more details check http state manager /// lib\controllers\http_status_manger\http_status_manger.dart - Future getTypes({String host, User user}) async { + Future getTypes() async { if (_loading == true) return -2; _loading = true; notifyListeners(); diff --git a/lib/controllers/providers/api/status_drop_down/report/service_types_provider.dart b/lib/controllers/providers/api/status_drop_down/report/service_types_provider.dart index 0a1d671b..1792694b 100644 --- a/lib/controllers/providers/api/status_drop_down/report/service_types_provider.dart +++ b/lib/controllers/providers/api/status_drop_down/report/service_types_provider.dart @@ -6,7 +6,6 @@ import 'package:http/http.dart'; import 'package:test_sa/controllers/api_routes/api_manager.dart'; import 'package:test_sa/controllers/api_routes/urls.dart'; import 'package:test_sa/models/lookup.dart'; -import 'package:test_sa/models/user.dart'; class ServiceStatusProvider extends ChangeNotifier { //reset provider data @@ -18,20 +17,20 @@ class ServiceStatusProvider extends ChangeNotifier { // state code of current request to defied error message // like 400 customer request failed // 500 service not available - int _stateCode; + int? _stateCode; - int get stateCode => _stateCode; + int? get stateCode => _stateCode; // contain user data // when user not login or register _user = null - List _statuses; + List? _statuses; - List get statuses => _statuses; + List? get statuses => _statuses; // when categories in-process _loading = true // done _loading = true // failed _loading = false - bool _loading; + bool _loading = false; bool get isLoading => _loading; @@ -45,15 +44,13 @@ class ServiceStatusProvider extends ChangeNotifier { /// return state code if request complete may be 200, 404 or 403 /// for more details check http state manager /// lib\controllers\http_status_manger\http_status_manger.dart - Future getTypes({String host, User user}) async { + Future getTypes() async { if (_loading == true) return -2; _loading = true; notifyListeners(); Response response; try { - response = await ApiManager.instance.get( - URLs.getAssetTypes, - ); + response = await ApiManager.instance.get(URLs.getAssetTypes); _stateCode = response.statusCode; if (response.statusCode >= 200 && response.statusCode < 300) { // client's request was successfully received diff --git a/lib/controllers/providers/api/user_provider.dart b/lib/controllers/providers/api/user_provider.dart index 6fe00e30..52cd2a19 100644 --- a/lib/controllers/providers/api/user_provider.dart +++ b/lib/controllers/providers/api/user_provider.dart @@ -19,13 +19,13 @@ class UserProvider extends ChangeNotifier { // contain user data // when user not login or register _user = null - User _user; + User? _user; - User get user => _user; + User? get user => _user; - File profileImage; + File? profileImage; - set user(User user) { + void setUser(User user) { _user = user; ApiManager.instance.user = user; notifyListeners(); @@ -48,19 +48,19 @@ class UserProvider extends ChangeNotifier { /// return state code if request complete may be 200, 404 or 403 /// for more details check http state manager /// lib\controllers\http_status_manger\http_status_manger.dart - Future login({@required BuildContext context, @required User user}) async { + Future login({required BuildContext context, required User user}) async { if (_loading == true) return -2; _loading = true; notifyListeners(); Response response; try { - showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading()); + showDialog(context: context, barrierDismissible: false, builder: (context) => AppLazyLoading()); response = await ApiManager.instance.post(URLs.login, body: await user.toLoginJson()); _loading = false; if (response.statusCode >= 200 && response.statusCode < 300) { // client's request was successfully received _user = User.fromJson(jsonDecode(response.body)); - _user.profilePhotoName = URLs.getFileUrl(_user.profilePhotoName); + _user!.profilePhotoName = URLs.getFileUrl(_user!.profilePhotoName); ApiManager.instance.user = _user; notifyListeners(); Navigator.pop(context); @@ -70,7 +70,7 @@ class UserProvider extends ChangeNotifier { Navigator.pop(context); return response.statusCode; } catch (error) { - // debugPrint(error); + // debugPrint(error); Navigator.pop(context); _loading = false; notifyListeners(); @@ -84,36 +84,36 @@ class UserProvider extends ChangeNotifier { /// return state code if request complete may be 200, 404 or 403 /// for more details about state codes check http state manager /// lib\controllers\http_status_manger\http_status_manger.dart - Future register({ - @required String host, - @required User user, - }) async { - if (_loading == true) return -2; - _loading = true; - notifyListeners(); - Response response; - try { - response = await ApiManager.instance.post( - URLs.register, - body: await user.toLoginJson(), - ); - } catch (error) { - _loading = false; - notifyListeners(); - return -1; - } - _loading = false; - notifyListeners(); - if (response.statusCode >= 200 && response.statusCode < 300) { - // client's request was successfully received - _user = User.fromJson(jsonDecode(utf8.decode(response.bodyBytes))[0]); - _user.clientId = user.clientId; - _user.clientName = user.clientName; - notifyListeners(); - return response.statusCode; - } - return response.statusCode; - } + // Future register({ + // required String host, + // required User user, + // }) async { + // if (_loading == true) return -2; + // _loading = true; + // notifyListeners(); + // Response response; + // try { + // response = await ApiManager.instance.post( + // URLs.register, + // body: await user.toLoginJson(), + // ); + // } catch (error) { + // _loading = false; + // notifyListeners(); + // return -1; + // } + // _loading = false; + // notifyListeners(); + // if (response.statusCode >= 200 && response.statusCode < 300) { + // // client's request was successfully received + // _user = User.fromJson(jsonDecode(utf8.decode(response.bodyBytes))[0]); + // _user!.clientId = user.clientId; + // _user!.clientName = user.clientName; + // notifyListeners(); + // return response.statusCode; + // } + // return response.statusCode; + // } Future uploadProfileImage(String userId, File image) async { if (_loading == true) return -2; @@ -129,7 +129,7 @@ class UserProvider extends ChangeNotifier { if (response.statusCode >= 200 && response.statusCode < 300) { profileImage = image; String imageId = jsonDecode(response.body)["data"]; - _user.profilePhotoName = URLs.getFileUrl(imageId); + _user!.profilePhotoName = URLs.getFileUrl(imageId); ApiManager.instance.user = _user; } _loading = false; @@ -143,8 +143,8 @@ class UserProvider extends ChangeNotifier { } // Future updateProfile({ -// @required String host, -// @required User user, +// required String host, +// required User user, // }) async { // if (_loading == true) return -2; // _loading = true; diff --git a/lib/dashboard_latest/dashboard_view.dart b/lib/dashboard_latest/dashboard_view.dart index 0306fbdc..9b8d95cd 100644 --- a/lib/dashboard_latest/dashboard_view.dart +++ b/lib/dashboard_latest/dashboard_view.dart @@ -22,7 +22,7 @@ import '../new_views/pages/land_page/dashboard_fragments/request_category_fragme class DashboardView extends StatefulWidget { final VoidCallback onDrawerPress; - const DashboardView({Key key, this.onDrawerPress}) : super(key: key); + const DashboardView({Key? key, required this.onDrawerPress}) : super(key: key); @override State createState() => _DashboardViewState(); @@ -31,15 +31,15 @@ class DashboardView extends StatefulWidget { class _DashboardViewState extends State { int _currentPage = 0; bool isFCM = true; - User user; + late User user; - SettingProvider settingProvider; - UserProvider userProvider; + late SettingProvider settingProvider; + late UserProvider userProvider; - AllRequestsProvider allRequestsProvider; + late AllRequestsProvider allRequestsProvider; - NotificationsProvider notificationsProvider; - ScrollController _scrollController; + late NotificationsProvider notificationsProvider; + late ScrollController _scrollController; @override void initState() { @@ -54,13 +54,13 @@ class _DashboardViewState extends State { settingProvider = Provider.of(context, listen: false); allRequestsProvider = Provider.of(context, listen: false); notificationsProvider = Provider.of(context, listen: false); - user = userProvider.user; + user = userProvider.user!; await getAllRequests(); if (isFCM) { FirebaseNotificationManger.initialized(context); NotificationManger.initialisation((notificationDetails) { - FirebaseNotificationManger.handleMessage(context, json.decode(notificationDetails.payload)); + FirebaseNotificationManger.handleMessage(context, json.decode(notificationDetails.payload!)); }, (id, title, body, payload) async {}); isFCM = false; @@ -73,7 +73,7 @@ class _DashboardViewState extends State { allRequestsProvider.isFilterRequestLoading = true; allRequestsProvider.currentListIndex = 0; allRequestsProvider.filterRequest = null; - var tabs = RequestUtils.getTabs(userType: userProvider.user.type, context: context); + var tabs = RequestUtils.getTabs(userType: userProvider.user!.type!, context: context); allRequestsProvider.status = tabs[0]['status']; allRequestsProvider.getRequests(); allRequestsProvider.pageNum = 1; @@ -81,7 +81,7 @@ class _DashboardViewState extends State { allRequestsProvider.requestDetailList = allRequestsProvider.filterRequest; }); allRequestsProvider.isAllLoading = false; - notificationsProvider.getSystemNotifications(user: userProvider.user, resetProvider: true); + notificationsProvider.getSystemNotifications(user: userProvider.user!, resetProvider: true); } void handleScroll() async { @@ -118,7 +118,7 @@ class _DashboardViewState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, - children: [14.height, ProgressFragment(), 25.height, SizedBox(height: 110.toScreenHeight, child: const RequestsFragment()), 16.height, const RequestCategoryFragment()], + children: [14.height, ProgressFragment(), 25.height, SizedBox(height: 110.toScreenHeight, child: RequestsFragment()), 16.height, RequestCategoryFragment()], ).paddingOnly(start: 16, end: 16, top: 0, bottom: 8), ), ), diff --git a/lib/dashboard_latest/widgets/app_bar_widget.dart b/lib/dashboard_latest/widgets/app_bar_widget.dart index ea13c125..8c7cc548 100644 --- a/lib/dashboard_latest/widgets/app_bar_widget.dart +++ b/lib/dashboard_latest/widgets/app_bar_widget.dart @@ -94,7 +94,7 @@ class AppBarWidget extends StatelessWidget { }); } }, - items: Provider.of(context, listen: false).user?.assetGroups.map>((value) { + items: Provider.of(context, listen: false).user?.assetGroups?.map>((value) { // Added null check and made AssetGroup nullable return DropdownMenuItem( value: value, diff --git a/lib/extensions/int_extensions.dart b/lib/extensions/int_extensions.dart index 9772bc24..a26bc794 100644 --- a/lib/extensions/int_extensions.dart +++ b/lib/extensions/int_extensions.dart @@ -9,7 +9,7 @@ extension IntExtensions on int { Widget get makeItSquare => SizedBox(width: toScreenWidth, height: toScreenWidth); - double get toScreenHeight => (this / 932) * SizeConfig.screenHeight; + double get toScreenHeight => (this / 932) * SizeConfig.screenHeight!; - double get toScreenWidth => (this / 430) * SizeConfig.screenWidth; + double get toScreenWidth => (this / 430) * SizeConfig.screenWidth!; } diff --git a/lib/main.dart b/lib/main.dart index 3b3ab99a..ecf46317 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -135,7 +135,7 @@ void main() async { final navigatorKey = GlobalKey(); class MyApp extends StatelessWidget { - const MyApp({Key key}) : super(key: key); + const MyApp({Key? key}) : super(key: key); // This widget is the root of your application. @override diff --git a/lib/models/device/asset_by_id_model.dart b/lib/models/device/asset_by_id_model.dart index 618a90cb..e358c16e 100644 --- a/lib/models/device/asset_by_id_model.dart +++ b/lib/models/device/asset_by_id_model.dart @@ -2,66 +2,66 @@ import 'package:test_sa/models/device/technical_guidance_book.dart'; import 'package:test_sa/models/lookup.dart'; class AssetByIdModel { - List multiAssets; - int id; - ModelDefinition modelDefinition; - Suppliers supplier; - String ipAddress; - String macAddress; - String portNumber; - AssetReplace assetReplace; - AssetInfo oldAsset; - AssetReplace isParent; - AssetInfo parentAsset; - AssetReplace assetType; - String demoRequest; - String missionCritical; - Site site; - AssetReplace building; - AssetReplace floor; - Department department; - Lookup room; - int testsDay; - num purchasingPrice; - String nbv; - String currency; - String poDate; - String poNo; - String invoiceNumber; - String invoiceDate; - String replacementDate; - num budgetYear; - num lastPOPrice; - Lookup commissioningStatus; - Department originDepartment; - Site originSite; - String productionDate; - String edd; - String technicalInspectionDate; - String deliveryInspectionDate; - String endUserAcceptanceDate; - String technicalAcceptanceDate; - String finalAcceptanceDate; - String installationDate; - int siteWarrantyMonthNo; - num extendedWarrantyMonthNo; - num remainderWarrantyMonthNo; - num eomWarrantyMonthsNo; - num warrantyValue; - String warrantyEndDate; - String warrantyContractConditions; - List technicalGuidanceBooks; - String comment; - bool isEnabled; - String tagCode; - List assetAttachments; - String retirementTypeName; - String retirementStatusName; - String retirementDate; - AssetGroup assetGroup; - String assetPhoto; - String nextPMDate; - String lastPMDate; + List? multiAssets; + int? id; + ModelDefinition? modelDefinition; + Suppliers? supplier; + String? ipAddress; + String? macAddress; + String? portNumber; + AssetReplace? assetReplace; + AssetInfo? oldAsset; + AssetReplace? isParent; + AssetInfo? parentAsset; + AssetReplace? assetType; + String? demoRequest; + String? missionCritical; + Site? site; + AssetReplace? building; + AssetReplace? floor; + Department? department; + Lookup? room; + int? testsDay; + num? purchasingPrice; + String? nbv; + String? currency; + String? poDate; + String? poNo; + String? invoiceNumber; + String? invoiceDate; + String? replacementDate; + num? budgetYear; + num? lastPOPrice; + Lookup? commissioningStatus; + Department? originDepartment; + Site? originSite; + String? productionDate; + String? edd; + String? technicalInspectionDate; + String? deliveryInspectionDate; + String? endUserAcceptanceDate; + String? technicalAcceptanceDate; + String? finalAcceptanceDate; + String? installationDate; + int? siteWarrantyMonthNo; + num? extendedWarrantyMonthNo; + num? remainderWarrantyMonthNo; + num? eomWarrantyMonthsNo; + num? warrantyValue; + String? warrantyEndDate; + String? warrantyContractConditions; + List? technicalGuidanceBooks; + String? comment; + bool? isEnabled; + String? tagCode; + List? assetAttachments; + String? retirementTypeName; + String? retirementStatusName; + String? retirementDate; + AssetGroup? assetGroup; + String? assetPhoto; + String? nextPMDate; + String? lastPMDate; AssetByIdModel( {this.multiAssets, @@ -129,7 +129,7 @@ class AssetByIdModel { if (json['multiAssets'] != null) { multiAssets = []; json['multiAssets'].forEach((v) { - multiAssets.add(new MultiAssets.fromJson(v)); + multiAssets!.add(new MultiAssets.fromJson(v)); }); } id = json['id']; @@ -149,7 +149,7 @@ class AssetByIdModel { building = json['building'] != null ? new AssetReplace.fromJson(json['building']) : null; floor = json['floor'] != null ? new AssetReplace.fromJson(json['floor']) : null; department = json['department'] != null ? new Department.fromJson(json['department']) : null; - room = json['room'] != null ? new Lookup.fromJson(json['room']) : null; + room = json['room'] != null ? Lookup.fromJson(json['room']) : null; testsDay = json['testsDay']; purchasingPrice = json['purchasingPrice']; nbv = json['nbv']; @@ -161,7 +161,7 @@ class AssetByIdModel { replacementDate = json['replacementDate']; budgetYear = json['budgetYear']; lastPOPrice = json['lastPOPrice']; - commissioningStatus = json['commissioningStatus'] != null ? new Lookup.fromJson(json['commissioningStatus']) : null; + commissioningStatus = json['commissioningStatus'] != null ? Lookup.fromJson(json['commissioningStatus']) : null; originDepartment = json['originDepartment'] != null ? new Department.fromJson(json['originDepartment']) : null; originSite = json['originSite'] != null ? new Site.fromJson(json['originSite']) : null; productionDate = json['productionDate']; @@ -182,22 +182,22 @@ class AssetByIdModel { if (json['technicalGuidanceBooks'] != null) { technicalGuidanceBooks = []; json['technicalGuidanceBooks'].forEach((v) { - technicalGuidanceBooks.add(TechnicalGuidanceBook.fromJson(v)); + technicalGuidanceBooks!.add(TechnicalGuidanceBook.fromJson(v)); }); } comment = json['comment']; isEnabled = json['isEnabled']; tagCode = json['tagCode']; if (json['assetAttachments'] != null) { - assetAttachments = []; + assetAttachments = []; json['assetAttachments'].forEach((v) { - assetAttachments.add(v); + assetAttachments!.add(v); }); } retirementTypeName = json['retirementTypeName']; retirementStatusName = json['retirementStatusName']; retirementDate = json['retirementDate']; - assetGroup = json['assetGroup'] != null ? new AssetGroup.fromJson(json['assetGroup']) : null; + assetGroup = json['assetGroup'] != null ? AssetGroup.fromJson(json['assetGroup']) : null; assetPhoto = json['assetPhoto']; nextPMDate = json['nextPMDate']; lastPMDate = json['lastPMDate']; @@ -206,44 +206,44 @@ class AssetByIdModel { Map toJson() { final Map data = new Map(); if (this.multiAssets != null) { - data['multiAssets'] = this.multiAssets.map((v) => v.toJson()).toList(); + data['multiAssets'] = this.multiAssets!.map((v) => v.toJson()).toList(); } data['id'] = this.id; if (this.modelDefinition != null) { - data['modelDefinition'] = this.modelDefinition.toJson(); + data['modelDefinition'] = this.modelDefinition?.toJson(); } if (this.supplier != null) { - data['supplier'] = this.supplier.toJson(); + data['supplier'] = this.supplier?.toJson(); } data['ipAddress'] = this.ipAddress; data['macAddress'] = this.macAddress; data['portNumber'] = this.portNumber; if (this.assetReplace != null) { - data['assetReplace'] = this.assetReplace.toJson(); + data['assetReplace'] = this.assetReplace?.toJson(); } data['oldAsset'] = this.oldAsset?.toJson(); if (this.isParent != null) { - data['isParent'] = this.isParent.toJson(); + data['isParent'] = this.isParent?.toJson(); } data['parentAsset'] = this.parentAsset?.toJson(); if (this.assetType != null) { - data['assetType'] = this.assetType.toJson(); + data['assetType'] = this.assetType?.toJson(); } data['demoRequest'] = this.demoRequest; data['missionCritical'] = this.missionCritical; if (this.site != null) { - data['site'] = this.site.toJson(); + data['site'] = this.site?.toJson(); } if (this.building != null) { - data['building'] = this.building.toJson(); + data['building'] = this.building?.toJson(); } if (this.floor != null) { - data['floor'] = this.floor.toJson(); + data['floor'] = this.floor?.toJson(); } if (this.department != null) { - data['department'] = this.department.toJson(); + data['department'] = this.department?.toJson(); } - data['room'] = this.room.toJson(); + data['room'] = this.room?.toJson(); data['testsDay'] = this.testsDay; data['purchasingPrice'] = this.purchasingPrice; data['nbv'] = this.nbv; @@ -257,10 +257,10 @@ class AssetByIdModel { data['lastPOPrice'] = this.lastPOPrice; data['commissioningStatus'] = this.commissioningStatus?.toJson(); if (this.originDepartment != null) { - data['originDepartment'] = this.originDepartment.toJson(); + data['originDepartment'] = this.originDepartment?.toJson(); } if (this.originSite != null) { - data['originSite'] = this.originSite.toJson(); + data['originSite'] = this.originSite?.toJson(); } data['productionDate'] = this.productionDate; data['edd'] = this.edd; @@ -278,19 +278,19 @@ class AssetByIdModel { data['warrantyEndDate'] = this.warrantyEndDate; data['warrantyContractConditions'] = this.warrantyContractConditions; if (this.technicalGuidanceBooks != null) { - data['technicalGuidanceBooks'] = this.technicalGuidanceBooks.map((v) => v).toList(); + data['technicalGuidanceBooks'] = this.technicalGuidanceBooks!.map((v) => v).toList(); } data['comment'] = this.comment; data['isEnabled'] = this.isEnabled; data['tagCode'] = this.tagCode; if (this.assetAttachments != null) { - data['assetAttachments'] = this.assetAttachments.map((v) => v).toList(); + data['assetAttachments'] = this.assetAttachments!.map((v) => v).toList(); } data['retirementTypeName'] = this.retirementTypeName; data['retirementStatusName'] = this.retirementStatusName; data['retirementDate'] = this.retirementDate; if (this.assetGroup != null) { - data['assetGroup'] = this.assetGroup.toJson(); + data['assetGroup'] = this.assetGroup?.toJson(); } data['assetPhoto'] = this.assetPhoto; data['nextPMDate'] = this.nextPMDate; @@ -300,9 +300,9 @@ class AssetByIdModel { } class MultiAssets { - String assetSerialNo; - String systemID; - String assetNumber; + String? assetSerialNo; + String? systemID; + String? assetNumber; MultiAssets({this.assetSerialNo, this.systemID, this.assetNumber}); @@ -322,20 +322,20 @@ class MultiAssets { } class ModelDefinition { - int id; - String assetName; - String assetDescription; - String modelDefCode; - String modelName; - int manufacturerId; - String manufacturerName; - String supplierName; - String replacementDate; - String essentialEquipement; - String businessCritical; - int lifeSpan; - List modelDefRelatedDefects; - List suppliers; + int? id; + String? assetName; + String? assetDescription; + String? modelDefCode; + String? modelName; + int? manufacturerId; + String? manufacturerName; + String? supplierName; + String? replacementDate; + String? essentialEquipement; + String? businessCritical; + int? lifeSpan; + List? modelDefRelatedDefects; + List? suppliers; ModelDefinition( {this.id, @@ -369,13 +369,13 @@ class ModelDefinition { if (json['modelDefRelatedDefects'] != null) { modelDefRelatedDefects = []; json['modelDefRelatedDefects'].forEach((v) { - modelDefRelatedDefects.add(ModelDefRelatedDefects.fromJson(v)); + modelDefRelatedDefects!.add(ModelDefRelatedDefects.fromJson(v)); }); } if (json['suppliers'] != null) { suppliers = []; json['suppliers'].forEach((v) { - suppliers.add(new Suppliers.fromJson(v)); + suppliers!.add(new Suppliers.fromJson(v)); }); } } @@ -395,18 +395,18 @@ class ModelDefinition { data['businessCritical'] = this.businessCritical; data['lifeSpan'] = this.lifeSpan; if (this.modelDefRelatedDefects != null) { - data['modelDefRelatedDefects'] = this.modelDefRelatedDefects.map((v) => v.toJson()).toList(); + data['modelDefRelatedDefects'] = this.modelDefRelatedDefects!.map((v) => v.toJson()).toList(); } if (this.suppliers != null) { - data['suppliers'] = this.suppliers.map((v) => v.toJson()).toList(); + data['suppliers'] = this.suppliers!.map((v) => v.toJson()).toList(); } return data; } } class Suppliers { - int id; - String suppliername; + int? id; + String? suppliername; Suppliers({this.id, this.suppliername}); @@ -424,9 +424,9 @@ class Suppliers { } class AssetReplace { - int id; - String name; - int value; + int? id; + String? name; + int? value; AssetReplace({this.id, this.name, this.value}); @@ -446,10 +446,10 @@ class AssetReplace { } class Site { - int id; - int customerCode; - String custName; - List buildings; + int? id; + int? customerCode; + String? custName; + List? buildings; Site({this.id, this.customerCode, this.custName, this.buildings}); @@ -460,7 +460,7 @@ class Site { if (json['buildings'] != null) { buildings = []; json['buildings'].forEach((v) { - buildings.add(new Buildings.fromJson(v)); + buildings!.add(new Buildings.fromJson(v)); }); } } @@ -471,17 +471,17 @@ class Site { data['customerCode'] = this.customerCode; data['custName'] = this.custName; if (this.buildings != null) { - data['buildings'] = this.buildings.map((v) => v.toJson()).toList(); + data['buildings'] = this.buildings!.map((v) => v.toJson()).toList(); } return data; } } class Buildings { - int id; - String name; - int value; - List floors; + int? id; + String? name; + int? value; + List? floors; Buildings({this.id, this.name, this.value, this.floors}); @@ -492,7 +492,7 @@ class Buildings { if (json['floors'] != null) { floors = []; json['floors'].forEach((v) { - floors.add(new Floors.fromJson(v)); + floors!.add(new Floors.fromJson(v)); }); } } @@ -503,17 +503,17 @@ class Buildings { data['name'] = this.name; data['value'] = this.value; if (this.floors != null) { - data['floors'] = this.floors.map((v) => v.toJson()).toList(); + data['floors'] = this.floors!.map((v) => v.toJson()).toList(); } return data; } } class Floors { - int id; - String name; - int value; - List departments; + int? id; + String? name; + int? value; + List? departments; Floors({this.id, this.name, this.value, this.departments}); @@ -524,7 +524,7 @@ class Floors { if (json['departments'] != null) { departments = []; json['departments'].forEach((v) { - departments.add(new Departments.fromJson(v)); + departments!.add(new Departments.fromJson(v)); }); } } @@ -535,15 +535,15 @@ class Floors { data['name'] = this.name; data['value'] = this.value; if (this.departments != null) { - data['departments'] = this.departments.map((v) => v.toJson()).toList(); + data['departments'] = this.departments!.map((v) => v.toJson()).toList(); } return data; } } class Departments { - int id; - String name; + int? id; + String? name; Departments({this.id, this.name}); @@ -561,10 +561,10 @@ class Departments { } class Department { - int id; - String departmentName; - String departmentCode; - String ntCode; + int? id; + String? departmentName; + String? departmentCode; + String? ntCode; Department({this.id, this.departmentName, this.departmentCode, this.ntCode}); @@ -586,9 +586,9 @@ class Department { } class AssetGroup { - int id; - String name; - String code; + int? id; + String? name; + String? code; AssetGroup({this.id, this.name, this.code}); @@ -622,16 +622,16 @@ class ModelDefRelatedDefects { estimatedTime = json['estimatedTime']; } - num id; - String defectName; - String workPerformed; - String estimatedTime; + num? id; + String? defectName; + String? workPerformed; + String? estimatedTime; ModelDefRelatedDefects copyWith({ - num id, - String defectName, - String workPerformed, - String estimatedTime, + num? id, + String? defectName, + String? workPerformed, + String? estimatedTime, }) => ModelDefRelatedDefects( id: id ?? this.id ?? 0, @@ -669,20 +669,20 @@ class AssetInfo { assetName = json['assetName']; } - num id; - String assetSerialNo; - String assetNumber; - String tagCode; - String systemId; - String assetName; + num? id; + String? assetSerialNo; + String? assetNumber; + String? tagCode; + String? systemId; + String? assetName; AssetInfo copyWith({ - num id, - String assetSerialNo, - String assetNumber, - String tagCode, - String systemId, - String assetName, + num? id, + String? assetSerialNo, + String? assetNumber, + String? tagCode, + String? systemId, + String? assetName, }) => AssetInfo( id: id ?? this.id, diff --git a/lib/models/device/asset_transfer.dart b/lib/models/device/asset_transfer.dart index 7030c7f1..fcbb8cf0 100644 --- a/lib/models/device/asset_transfer.dart +++ b/lib/models/device/asset_transfer.dart @@ -103,7 +103,7 @@ class AssetTransfer { if (json['senderAttachments'] != null) { senderAttachments = []; json['senderAttachments'].forEach((v) { - senderAttachments.add(AssetTransferAttachment.fromJson(v)); + senderAttachments!.add(AssetTransferAttachment.fromJson(v)); }); } receiverAssignedEmployeeId = json['receiverAssignedEmployeeId']; @@ -117,13 +117,13 @@ class AssetTransfer { senderVisitTimers = []; if (json['assetTransferSenderTimers'] != null) { json['assetTransferSenderTimers'].forEach((v) { - senderVisitTimers.add(VisitTimers.fromJson(v)); + senderVisitTimers!.add(VisitTimers.fromJson(v)); }); } receiverVisitTimers = []; if (json['assetTransferReceiverTimers'] != null) { json['assetTransferReceiverTimers'].forEach((v) { - receiverVisitTimers.add(VisitTimers.fromJson(v)); + receiverVisitTimers!.add(VisitTimers.fromJson(v)); }); } tbsTimer = TimerModel(); @@ -144,7 +144,7 @@ class AssetTransfer { if (json['receiverAttachments'] != null) { receiverAttachments = []; json['receiverAttachments'].forEach((v) { - receiverAttachments.add(AssetTransferAttachment.fromJson(v)); + receiverAttachments!.add(AssetTransferAttachment.fromJson(v)); }); } assetNumber = json['assetNumber']; @@ -175,137 +175,137 @@ class AssetTransfer { supplierName = json['supplierName']; } - num id; - num transferNo; - String transferCode; - String assetSerialNo; - num assetId; - String assetNumber; - String assetName; - int modelId; - String modelName; - int manufacturerId; - String manufacturerName; - num destSiteId; - num destBuildingId; - num destFloorId; - num destDepartmentId; - num destRoomId; - num senderSiteId; - num senderBuildingId; - num senderFloorId; - num senderDepartmentId; - String senderRoom; - String senderAssignedEmployeeId; - num senderMachineStatusId; - String senderComment; - String comment; - String receiverEndUserId; - String receiverEndUserName; - String senderStartDate; - String senderEndDate; - String senderWorkingHours; - String senderTravelingHours; - String senderEngSignature; - List senderAttachments; - String receiverAssignedEmployeeId; - num receiverMachineStatusId; - String receiverComment; - String receiverStartDate; - String receiverEndDate; - String receiverWorkingHours; - String receiverTravelingHours; - String receiverEngSignature; - List receiverAttachments; - num supplierId; - String supplierName; - String destSiteName; - String destBuildingName; - String destFloorName; - String destDepartmentName; - String senderSiteName; - String senderBuildingName; - String senderFloorName; - String senderDepartmentName; - String senderAssignedEmployeeName; - String senderMachineStatusName; - String senderEngSignatureUrl; - String receiverAssignedEmployeeName; - String receiverMachineStatusName; - String receiverEngSignatureUrl; - bool applied; - String createdOn; - String modifiedOn; - List senderVisitTimers; - List receiverVisitTimers; - TimerModel tbsTimer = TimerModel(); + num? id; + num? transferNo; + String? transferCode; + String? assetSerialNo; + num? assetId; + String? assetNumber; + String? assetName; + int? modelId; + String? modelName; + int? manufacturerId; + String? manufacturerName; + num? destSiteId; + num? destBuildingId; + num? destFloorId; + num? destDepartmentId; + num? destRoomId; + num? senderSiteId; + num? senderBuildingId; + num? senderFloorId; + num? senderDepartmentId; + String? senderRoom; + String? senderAssignedEmployeeId; + num? senderMachineStatusId; + String? senderComment; + String? comment; + String? receiverEndUserId; + String? receiverEndUserName; + String? senderStartDate; + String? senderEndDate; + String? senderWorkingHours; + String? senderTravelingHours; + String? senderEngSignature; + List? senderAttachments; + String? receiverAssignedEmployeeId; + num? receiverMachineStatusId; + String? receiverComment; + String? receiverStartDate; + String? receiverEndDate; + String? receiverWorkingHours; + String? receiverTravelingHours; + String? receiverEngSignature; + List? receiverAttachments; + num? supplierId; + String? supplierName; + String? destSiteName; + String? destBuildingName; + String? destFloorName; + String? destDepartmentName; + String? senderSiteName; + String? senderBuildingName; + String? senderFloorName; + String? senderDepartmentName; + String? senderAssignedEmployeeName; + String? senderMachineStatusName; + String? senderEngSignatureUrl; + String? receiverAssignedEmployeeName; + String? receiverMachineStatusName; + String? receiverEngSignatureUrl; + bool? applied; + String? createdOn; + String? modifiedOn; + List? senderVisitTimers; + List? receiverVisitTimers; + TimerModel? tbsTimer = TimerModel(); AssetTransfer copyWith( - {num id, - num transferNo, - String transferCode, - num assetId, - num destSiteId, - num destBuildingId, - num destFloorId, - num destDepartmentId, - String destRoomId, - num senderSiteId, - num senderBuildingId, - num senderFloorId, - num senderDepartmentId, - String senderRoom, - String senderAssignedEmployeeId, - num senderMachineStatusId, - String senderComment, - String comment, - String receiverEndUserId, - String receiverEndUserName, - String senderStartDate, - String senderEndDate, - String senderWorkingHours, - String senderTravelingHours, - String senderEngSignature, - List senderAttachments, - String receiverAssignedEmployeeId, - num receiverMachineStatusId, - String receiverComment, - String receiverStartDate, - String receiverEndDate, - String receiverWorkingHours, - String receiverTravelingHours, - String receiverEngSignature, - List receiverAttachments, - num supplierId, - String supplierName, - String destSiteName, - String destBuildingName, - String destFloorName, - String destDepartmentNam, - String senderSiteName, - String senderBuildingName, - String senderFloorName, - String senderDepartmentName, - String senderAssignedEmployeeName, - String senderMachineStatusName, - String senderEngSignatureUrl, - String receiverAssignedEmployeeName, - String receiverMachineStatusName, - String receiverEngSignatureUrl, - bool applied, - String createdOn, - String modifiedOn, - String assetSerialNo, - String assetNumber, - String assetName, - int modelId, - String modelName, - int manufacturerId, - String manufacturerName, - String destDepartmentName, - List senderVisitTimers, - List receiverVisitTimers, - TimerModel tbsTimer}) => + {num? id, + num? transferNo, + String? transferCode, + num? assetId, + num? destSiteId, + num? destBuildingId, + num? destFloorId, + num? destDepartmentId, + num? destRoomId, + num? senderSiteId, + num? senderBuildingId, + num? senderFloorId, + num? senderDepartmentId, + String? senderRoom, + String? senderAssignedEmployeeId, + num? senderMachineStatusId, + String? senderComment, + String? comment, + String? receiverEndUserId, + String? receiverEndUserName, + String? senderStartDate, + String? senderEndDate, + String? senderWorkingHours, + String? senderTravelingHours, + String? senderEngSignature, + List? senderAttachments, + String? receiverAssignedEmployeeId, + num? receiverMachineStatusId, + String? receiverComment, + String? receiverStartDate, + String? receiverEndDate, + String? receiverWorkingHours, + String? receiverTravelingHours, + String? receiverEngSignature, + List? receiverAttachments, + num? supplierId, + String? supplierName, + String? destSiteName, + String? destBuildingName, + String? destFloorName, + String? destDepartmentNam, + String? senderSiteName, + String? senderBuildingName, + String? senderFloorName, + String? senderDepartmentName, + String? senderAssignedEmployeeName, + String? senderMachineStatusName, + String? senderEngSignatureUrl, + String? receiverAssignedEmployeeName, + String? receiverMachineStatusName, + String? receiverEngSignatureUrl, + bool? applied, + String? createdOn, + String? modifiedOn, + String? assetSerialNo, + String? assetNumber, + String? assetName, + int? modelId, + String? modelName, + int? manufacturerId, + String? manufacturerName, + String? destDepartmentName, + List? senderVisitTimers, + List? receiverVisitTimers, + TimerModel? tbsTimer}) => AssetTransfer( id: id ?? this.id, transferNo: transferNo ?? this.transferNo, @@ -400,13 +400,13 @@ class AssetTransfer { map['senderTravelingHours'] = senderTravelingHours; map['senderEngSignature'] = senderEngSignature; if (this.senderVisitTimers != null) { - map['assetTransferSenderTimers'] = this.senderVisitTimers.map((v) => v.toJson()).toList(); + map['assetTransferSenderTimers'] = this.senderVisitTimers!.map((v) => v.toJson()).toList(); } if (this.receiverVisitTimers != null) { - map['assetTransferReceiverTimers'] = this.receiverVisitTimers.map((v) => v.toJson()).toList(); + map['assetTransferReceiverTimers'] = this.receiverVisitTimers!.map((v) => v.toJson()).toList(); } if (senderAttachments != null) { - map['senderAttachments'] = senderAttachments.map((v) => v.toJson()).toList(); + map['senderAttachments'] = senderAttachments!.map((v) => v.toJson()).toList(); } map['receiverAssignedEmployeeId'] = receiverAssignedEmployeeId; map['receiverMachineStatusId'] = receiverMachineStatusId; @@ -417,7 +417,7 @@ class AssetTransfer { map['receiverTravelingHours'] = receiverTravelingHours; map['receiverEngSignature'] = receiverEngSignature; if (receiverAttachments != null) { - map['receiverAttachments'] = receiverAttachments.map((v) => v.toJson()).toList(); + map['receiverAttachments'] = receiverAttachments!.map((v) => v.toJson()).toList(); } map["supplierId"] = supplierId; map["supplierName"] = supplierName; @@ -448,7 +448,7 @@ class AssetTransfer { return map; } - Map transferBody({Asset asset}) { + Map transferBody({Asset? asset}) { final map = {}; map['id'] = 0; map['transferNo'] = transferNo; @@ -476,13 +476,13 @@ class AssetTransfer { map['senderTravelingHours'] = senderTravelingHours; map['senderEngSignature'] = senderEngSignature; if (senderAttachments != null) { - map['senderAttachments'] = senderAttachments.map((v) => v.toJson()).toList(); + map['senderAttachments'] = senderAttachments!.map((v) => v.toJson()).toList(); } if (senderVisitTimers != null) { - map['assetTransferSenderTimers'] = senderVisitTimers.map((v) => v.toJson()).toList(); + map['assetTransferSenderTimers'] = senderVisitTimers!.map((v) => v.toJson()).toList(); } if (receiverVisitTimers != null) { - map['assetTransferReceiverTimers'] = receiverVisitTimers.map((v) => v.toJson()).toList(); + map['assetTransferReceiverTimers'] = receiverVisitTimers!.map((v) => v.toJson()).toList(); } map['receiverAssignedEmployeeId'] = receiverAssignedEmployeeId; map['receiverMachineStatusId'] = receiverMachineStatusId; @@ -493,12 +493,12 @@ class AssetTransfer { map['receiverTravelingHours'] = receiverTravelingHours; map['receiverEngSignature'] = receiverEngSignature; if (receiverAttachments != null) { - map['receiverAttachments'] = receiverAttachments.map((v) => v.toJson()).toList(); + map['receiverAttachments'] = receiverAttachments!.map((v) => v.toJson()).toList(); } return map; } - fromDetails(AssetTransfer assetTransfer) { + fromDetails(AssetTransfer? assetTransfer) { if (assetTransfer == null) return; id = assetTransfer.id; transferNo = assetTransfer.transferNo; diff --git a/lib/models/lookup.dart b/lib/models/lookup.dart index f1c0943b..2f691aeb 100644 --- a/lib/models/lookup.dart +++ b/lib/models/lookup.dart @@ -1,25 +1,29 @@ import 'base.dart'; class Lookup extends Base { - final int? id; // Now nullable - final int? value;// Now nullable + int? id; // Now nullable + int? value; // Now nullable + String? name; // Now nullable - Lookup({this.id, this.value, String? name}) : super(identifier: id?.toString(), name: name); + Lookup({this.id, this.value, this.name}) : super(identifier: id?.toString(), name: name); @override - bool operator ==(Object other) => identical(this, other) || other is Lookup && ((value != null && value ==other.value) || (id != null && id == other.id)); + bool operator ==(Object other) => identical(this, other) || other is Lookup && ((value != null && value == other.value) || (id != null && id == other.id)); @override int get hashCode => id.hashCode ^ value.hashCode; // Use XOR for hash code combination - Map toJson() { // Return a Map instead of calling a function + Map toJson() { + // Return a Map instead of calling a function return {"id": id, "name": name, "value": value}; } - static Lookup? fromStatus(Lookup? old) { // Now accepts nullable Lookup and returns nullable Lookup + static Lookup? fromStatus(Lookup? old) { + // Now accepts nullable Lookup and returns nullable Lookup if (old == null) return null; return Lookup( - name: old.name,id: old.id, + name: old.name, + id: old.id, value: old.value, ); } @@ -29,12 +33,12 @@ class Lookup extends Base { // userName = json['userName'] ?? ''; // } - Lookup.fromJson(Map? parsedJson) { // Now accepts nullable Map and returns nullable Lookup - if (parsedJson == null) return null; + factory Lookup.fromJson(Map parsedJson) { + // if (parsedJson == null) return null; return Lookup( name: parsedJson["name"], id: parsedJson["id"], value: parsedJson["value"], ); } -} \ No newline at end of file +} diff --git a/lib/models/service_request/call_site_contact_person.dart b/lib/models/service_request/call_site_contact_person.dart index b1c1494b..5b83704e 100644 --- a/lib/models/service_request/call_site_contact_person.dart +++ b/lib/models/service_request/call_site_contact_person.dart @@ -1,44 +1,45 @@ class CallSiteContactPerson { CallSiteContactPerson({ this.id, - this.employeeCode, - this.name, - this.telephone, - this.job, - this.email, - this.land, - this.contactUserId, + this.employeeCode = "", // Provide default value + this.name = "", // Provide default value + this.telephone = "", // Provide default value + this.job = "", // Provide default value + this.email = "", // Provide default value + this.land = "", // Provide default value + this.contactUserId = "", // Provide default value }); - CallSiteContactPerson.fromJson(dynamic json) { + CallSiteContactPerson.fromJson(Map json) { + // Specify Map type id = json['id']; - employeeCode = json['employeeCode']; - name = json['name']; - telephone = json['telephone']; - job = json['job']; - email = json['email']; - land = json['land']; - contactUserId = json['contactUserId']; + employeeCode = json['employeeCode'] ?? ""; // Provide default value if null + name = json['name'] ?? ""; // Provide default value if null + telephone = json['telephone'] ?? ""; // Provide default value if null + job = json['job'] ?? ""; // Provide default value if null + email = json['email'] ?? ""; // Provide default value if null + land = json['land'] ?? ""; // Provide default value if null + contactUserId = json['contactUserId'] ?? ""; // Provide default value if null } - num id; - String employeeCode; - String name; - String telephone; - String job; - String email; - String land; - String contactUserId; + num? id; + String? employeeCode; + String? name; + String? telephone; + String? job; + String? email; + String? land; + String? contactUserId; CallSiteContactPerson copyWith({ - num id, - String employeeCode, - String name, - String telephone, - String job, - String email, - String land, - String contactUserId, + num? id, + String? employeeCode, + String? name, + String? telephone, + String? job, + String? email, + String? land, + String? contactUserId, }) => CallSiteContactPerson( id: id ?? this.id, diff --git a/lib/models/service_request/contact_person_work_order.dart b/lib/models/service_request/contact_person_work_order.dart index cf43feb5..ec57369c 100644 --- a/lib/models/service_request/contact_person_work_order.dart +++ b/lib/models/service_request/contact_person_work_order.dart @@ -21,24 +21,24 @@ class ContactPersonWorkOrder { contactUserId = json['contactUserId']; } - num id; - String employeeCode; - String name; - String telephone; - String job; - String email; - String land; - String contactUserId; + num? id; + String? employeeCode; + String? name; + String? telephone; + String? job; + String? email; + String? land; + String? contactUserId; ContactPersonWorkOrder copyWith({ - num id, - String employeeCode, - String name, - String telephone, - String job, - String email, - String land, - String contactUserId, + num? id, + String? employeeCode, + String? name, + String? telephone, + String? job, + String? email, + String? land, + String? contactUserId, }) => ContactPersonWorkOrder( id: id ?? this.id, diff --git a/lib/models/service_request/pending_service_request_model.dart b/lib/models/service_request/pending_service_request_model.dart index 201c2824..5c5931b2 100644 --- a/lib/models/service_request/pending_service_request_model.dart +++ b/lib/models/service_request/pending_service_request_model.dart @@ -1,6 +1,6 @@ class PendingAssetServiceRequest { - String headerMessage; - List
details; + String? headerMessage; + List
? details; PendingAssetServiceRequest({this.headerMessage, this.details}); @@ -9,7 +9,7 @@ class PendingAssetServiceRequest { details =
[]; if (json['details'] != null) { json['details'].forEach((v) { - details.add(new Details.fromJson(v)); + details!.add(new Details.fromJson(v)); }); } } @@ -18,18 +18,18 @@ class PendingAssetServiceRequest { final Map data = new Map(); data['headerMessage'] = this.headerMessage; if (this.details != null) { - data['details'] = this.details.map((v) => v.toJson()).toList(); + data['details'] = this.details!.map((v) => v.toJson()).toList(); } return data; } } class Details { - int id; - String message; - String callComments; - String voiceNote; - String createdBy; + int? id; + String? message; + String? callComments; + String? voiceNote; + String? createdBy; Details({this.id, this.message}); diff --git a/lib/models/service_request/search_work_order.dart b/lib/models/service_request/search_work_order.dart index f26aec6d..44d3a549 100644 --- a/lib/models/service_request/search_work_order.dart +++ b/lib/models/service_request/search_work_order.dart @@ -17,44 +17,43 @@ import '../new_models/assistant_employee.dart'; import 'contact_person_work_order.dart'; class SearchWorkOrder { - SearchWorkOrder({ - this.id, - this.parentWOId, - this.workOrderNo, - this.workOrderYear, - this.workOrderSequennce, - this.callRequest, - this.assetType, - this.assignedEmployee, - this.visitDate, - this.assistantEmployees, - this.supplier, - this.vendorTicketNumber, - this.contactPersonWorkOrders, - this.calllastSituation, - this.currentSituation, - this.repairLocation, - this.reason, - // this.startofWorkTime, - // this.endofWorkTime, - this.workingHours, - this.travelingHours, - this.travelingExpenses, - this.faultDescription, - this.sparePartsWorkOrders, - this.reviewComment, - this.comment, - this.attachmentsWorkOrder, - this.equipmentStatus, - this.suppEngineerWorkOrders, - this.engSignature, - this.nurseSignature, - this.woParentDto, - this.timer, - this.mrNumber, - this.loanAvailablity, - this.assetLoan - }); + SearchWorkOrder( + {this.id, + this.parentWOId, + this.workOrderNo, + this.workOrderYear, + this.workOrderSequennce, + this.callRequest, + this.assetType, + this.assignedEmployee, + this.visitDate, + this.assistantEmployees, + this.supplier, + this.vendorTicketNumber, + this.contactPersonWorkOrders, + this.calllastSituation, + this.currentSituation, + this.repairLocation, + this.reason, + // this.startofWorkTime, + // this.endofWorkTime, + this.workingHours, + this.travelingHours, + this.travelingExpenses, + this.faultDescription, + this.sparePartsWorkOrders, + this.reviewComment, + this.comment, + this.attachmentsWorkOrder, + this.equipmentStatus, + this.suppEngineerWorkOrders, + this.engSignature, + this.nurseSignature, + this.woParentDto, + this.timer, + this.mrNumber, + this.loanAvailablity, + this.assetLoan}); SearchWorkOrder.fromJson(dynamic json) { id = json['id']; @@ -70,7 +69,7 @@ class SearchWorkOrder { if (json['assistantEmployees'] != null) { assistantEmployees = []; json['assistantEmployees'].forEach((v) { - assistantEmployees.add(AssistantEmployees.fromJson(v)); + assistantEmployees!.add(AssistantEmployees.fromJson(v)); }); } supplier = json['supplier'] != null ? SupplierDetails.fromJson(json['supplier']) : null; @@ -78,7 +77,7 @@ class SearchWorkOrder { if (json['contactPersonWorkOrders'] != null) { contactPersonWorkOrders = []; json['contactPersonWorkOrders'].forEach((v) { - contactPersonWorkOrders.add(ContactPersonWorkOrder.fromJson(v)); + contactPersonWorkOrders!.add(ContactPersonWorkOrder.fromJson(v)); }); } calllastSituation = json['calllastSituation'] != null ? Lookup.fromJson(json['calllastSituation']) : null; @@ -90,8 +89,8 @@ class SearchWorkOrder { if (json['startofWorkTime'] != null || json['endofWorkTime'] != null) { timer = TimerModel(); } - if (json['startofWorkTime'] != null) timer.startAt = DateTime.tryParse(json['startofWorkTime']); - if (json['endofWorkTime'] != null) timer.endAt = DateTime.tryParse(json['endofWorkTime']); + if (json['startofWorkTime'] != null) timer!.startAt = DateTime.tryParse(json['startofWorkTime']); + if (json['endofWorkTime'] != null) timer!.endAt = DateTime.tryParse(json['endofWorkTime']); workingHours = json['workingHours']; travelingHours = json['travelingHours']; travelingExpenses = json['travelingExpenses']; @@ -99,7 +98,7 @@ class SearchWorkOrder { if (json['sparePartsWorkOrders'] != null) { sparePartsWorkOrders = []; json['sparePartsWorkOrders'].forEach((v) { - sparePartsWorkOrders.add(SparePartsWorkOrders.fromJson(v)); + sparePartsWorkOrders!.add(SparePartsWorkOrders.fromJson(v)); }); } reviewComment = json['reviewComment']; @@ -107,14 +106,14 @@ class SearchWorkOrder { if (json['attachmentsWorkOrder'] != null) { attachmentsWorkOrder = []; json['attachmentsWorkOrder'].forEach((v) { - attachmentsWorkOrder.add(Attachment.fromJson(v)); + attachmentsWorkOrder!.add(Attachment.fromJson(v)); }); } equipmentStatus = json['equipmentStatus'] != null ? Lookup.fromJson(json['equipmentStatus']) : null; if (json['suppEngineerWorkOrders'] != null) { suppEngineerWorkOrders = []; json['suppEngineerWorkOrders'].forEach((v) { - suppEngineerWorkOrders.add(SuppEngineerWorkOrders.fromJson(v)); + suppEngineerWorkOrders!.add(SuppEngineerWorkOrders.fromJson(v)); }); } engSignature = json['engSignature']; @@ -165,85 +164,85 @@ class SearchWorkOrder { mrNumber = wo.mrNumber ?? mrNumber; } - num id; - num parentWOId; - String workOrderNo; - num workOrderYear; - num workOrderSequennce; - CallRequest callRequest; - Lookup assetType; - AssignedEmployee assignedEmployee; - String visitDate; - List assistantEmployees; - SupplierDetails supplier; - String vendorTicketNumber; - List contactPersonWorkOrders; - Lookup calllastSituation; - Lookup currentSituation; - Lookup repairLocation; - Lookup reason; + num? id; + num? parentWOId; + String? workOrderNo; + num? workOrderYear; + num? workOrderSequennce; + CallRequest? callRequest; + Lookup? assetType; + AssignedEmployee? assignedEmployee; + String? visitDate; + List? assistantEmployees; + SupplierDetails? supplier; + String? vendorTicketNumber; + List? contactPersonWorkOrders; + Lookup? calllastSituation; + Lookup? currentSituation; + Lookup? repairLocation; + Lookup? reason; // String startofWorkTime; // String endofWorkTime; - num workingHours; - num travelingHours; - num travelingExpenses; - FaultDescription faultDescription; - List sparePartsWorkOrders; - String reviewComment; - String comment; - List attachmentsWorkOrder; - Lookup equipmentStatus; - List suppEngineerWorkOrders; - String engSignature; - Uint8List localEngSignature; - String nurseSignature; - Uint8List localNurseSignature; - WoParent woParentDto; - TimerModel timer; - String mrNumber; + num? workingHours; + num? travelingHours; + num? travelingExpenses; + FaultDescription? faultDescription; + List? sparePartsWorkOrders; + String? reviewComment; + String? comment; + List? attachmentsWorkOrder; + Lookup? equipmentStatus; + List? suppEngineerWorkOrders; + String? engSignature; + Uint8List? localEngSignature; + String? nurseSignature; + Uint8List? localNurseSignature; + WoParent? woParentDto; + TimerModel? timer; + String? mrNumber; - Lookup loanAvailablity; + Lookup? loanAvailablity; - AssetInfo assetLoan; + AssetInfo? assetLoan; SearchWorkOrder copyWith({ - num id, - num parentWOId, - String workOrderNo, - num workOrderYear, - num workOrderSequennce, - CallRequest callRequest, - Lookup assetType, - AssignedEmployee assignedEmployee, - String visitDate, - List assistantEmployees, - SupplierDetails supplier, - String vendorTicketNumber, - List contactPersonWorkOrders, - Lookup calllastSituation, - Lookup currentSituation, - Lookup repairLocation, - Lookup reason, + num? id, + num? parentWOId, + String? workOrderNo, + num? workOrderYear, + num? workOrderSequennce, + CallRequest? callRequest, + Lookup? assetType, + AssignedEmployee? assignedEmployee, + String? visitDate, + List? assistantEmployees, + SupplierDetails? supplier, + String? vendorTicketNumber, + List? contactPersonWorkOrders, + Lookup? calllastSituation, + Lookup? currentSituation, + Lookup? repairLocation, + Lookup? reason, // String startofWorkTime, // String endofWorkTime, - num workingHours, - num travelingHours, - num travelingExpenses, - FaultDescription faultDescription, - List sparePartsWorkOrders, - String reviewComment, - String comment, - List attachmentsWorkOrder, - Lookup equipmentStatus, - List suppEngineerWorkOrders, - String engSignature, - String nurseSignature, - WoParent woParentDto, - TimerModel timer, - String mrNumber, - Lookup loanAvailablity, - AssetInfo assetLoan, + num? workingHours, + num? travelingHours, + num? travelingExpenses, + FaultDescription? faultDescription, + List? sparePartsWorkOrders, + String? reviewComment, + String? comment, + List? attachmentsWorkOrder, + Lookup? equipmentStatus, + List? suppEngineerWorkOrders, + String? engSignature, + String? nurseSignature, + WoParent? woParentDto, + TimerModel? timer, + String? mrNumber, + Lookup? loanAvailablity, + AssetInfo? assetLoan, }) => SearchWorkOrder( id: id ?? this.id, @@ -292,34 +291,34 @@ class SearchWorkOrder { map['workOrderYear'] = workOrderYear; map['workOrderSequennce'] = workOrderSequennce; if (callRequest != null) { - map['callRequest'] = callRequest.toJson(); + map['callRequest'] = callRequest!.toJson(); } if (assetType != null) { - map['assetType'] = assetType.toJson(); + map['assetType'] = assetType!.toJson(); } if (assignedEmployee != null) { - map['assignedEmployee'] = assignedEmployee.toJson(); + map['assignedEmployee'] = assignedEmployee!.toJson(); } map['visitDate'] = visitDate; if (assistantEmployees != null) { - map['assistantEmployees'] = assistantEmployees.map((v) => v?.toJson()).toList(); + map['assistantEmployees'] = assistantEmployees!.map((v) => v?.toJson()).toList(); } if (supplier != null) { - map['supplier'] = supplier.toJson(); + map['supplier'] = supplier!.toJson(); } map['vendorTicketNumber'] = vendorTicketNumber; if (contactPersonWorkOrders != null) { - map['contactPersonWorkOrders'] = contactPersonWorkOrders.map((v) => v.toJson()).toList(); + map['contactPersonWorkOrders'] = contactPersonWorkOrders!.map((v) => v.toJson()).toList(); } if (calllastSituation != null) { - map['calllastSituation'] = calllastSituation.toJson(); + map['calllastSituation'] = calllastSituation!.toJson(); } map['currentSituation'] = currentSituation?.toJson(); if (repairLocation?.id != null) { - map['repairLocation'] = repairLocation.toJson(); + map['repairLocation'] = repairLocation!.toJson(); } - if (reason != null && reason.id != null) { - map['reason'] = reason.toJson(); + if (reason?.id != null) { + map['reason'] = reason!.toJson(); } // map['startofWorkTime'] = startofWorkTime; // map['endofWorkTime'] = endofWorkTime; @@ -330,35 +329,35 @@ class SearchWorkOrder { map['travelingExpenses'] = travelingExpenses; if (faultDescription?.id != null) { - map['faultDescription'] = faultDescription.toJson(); + map['faultDescription'] = faultDescription!.toJson(); } if (sparePartsWorkOrders != null) { - map['sparePartsWorkOrders'] = sparePartsWorkOrders.map((v) => v.toJson()).toList(); + map['sparePartsWorkOrders'] = sparePartsWorkOrders!.map((v) => v.toJson()).toList(); } map['reviewComment'] = reviewComment; map['comment'] = comment; if (attachmentsWorkOrder != null) { - map['attachmentsWorkOrder'] = attachmentsWorkOrder.map((v) => v.toJson()).toList(); + map['attachmentsWorkOrder'] = attachmentsWorkOrder!.map((v) => v.toJson()).toList(); } - if (equipmentStatus != null && equipmentStatus.id != null) { - map['equipmentStatus'] = equipmentStatus.toJson(); + if ( equipmentStatus?.id != null) { + map['equipmentStatus'] = equipmentStatus!.toJson(); } if (suppEngineerWorkOrders != null) { - map['suppEngineerWorkOrders'] = suppEngineerWorkOrders.map((v) => v.toJson()).toList(); + map['suppEngineerWorkOrders'] = suppEngineerWorkOrders!.map((v) => v.toJson()).toList(); } map['engSignature'] = engSignature; map['nurseSignature'] = nurseSignature; if (woParentDto != null) { - map['woParentDto'] = woParentDto.toJson(); + map['woParentDto'] = woParentDto!.toJson(); } if (mrNumber != null) { map['mrNumber'] = mrNumber; } if (loanAvailablity != null) { - map['loanAvailablity'] = loanAvailablity.toJson(); + map['loanAvailablity'] = loanAvailablity!.toJson(); } if (assetLoan != null) { - map['assetLoan'] = assetLoan.toJson(); + map['assetLoan'] = assetLoan!.toJson(); } return map; } diff --git a/lib/models/service_request/service_report.dart b/lib/models/service_request/service_report.dart index 75237bed..83dfa4f3 100644 --- a/lib/models/service_request/service_report.dart +++ b/lib/models/service_request/service_report.dart @@ -74,7 +74,7 @@ class ServiceReport { if (json['assistantEmployees'] != null) { assistantEmployees = []; json['assistantEmployees'].forEach((v) { - assistantEmployees.add(AssistantEmployees.fromJson(v)); + assistantEmployees!.add(AssistantEmployees.fromJson(v)); }); } supplier = json['supplier'] != null ? SupplierDetails.fromJson(json['supplier']) : null; @@ -83,7 +83,7 @@ class ServiceReport { if (json['contactPersonWorkOrders'] != null) { contactPersonWorkOrders = []; json['contactPersonWorkOrders'].forEach((v) { - contactPersonWorkOrders.add(ContactPersonWorkOrder.fromJson(v)); + contactPersonWorkOrders!.add(ContactPersonWorkOrder.fromJson(v)); }); } calllastSituation = json['calllastSituation'] != null ? Lookup.fromJson(json['calllastSituation']) : null; @@ -96,9 +96,9 @@ class ServiceReport { workingHours = json['workingHours']; try { timer = TimerModel(startAt: DateTime.tryParse(startofWorkTime ?? ""), endAt: DateTime.tryParse(endofWorkTime ?? "")); - if (timer.endAt != null && timer.startAt != null) { - timer.durationInSecond = (timer.endAt.difference(timer.startAt))?.inSeconds; - workingHours = (((timer.durationInSecond ?? 0) / 60) / 60); + if (timer!.endAt != null && timer!.startAt != null) { + timer!.durationInSecond = (timer!.endAt!.difference(timer!.startAt!)).inSeconds; + workingHours = (((timer!.durationInSecond ?? 0) / 60) / 60); } } catch (e) { print(e); @@ -109,7 +109,7 @@ class ServiceReport { if (json['sparePartsWorkOrders'] != null) { sparePartsWorkOrders = []; json['sparePartsWorkOrders'].forEach((v) { - sparePartsWorkOrders.add(SparePartsWorkOrders.fromJson(v)); + sparePartsWorkOrders!.add(SparePartsWorkOrders.fromJson(v)); }); } reviewComment = json['reviewComment']; @@ -118,14 +118,14 @@ class ServiceReport { attachmentsWorkOrder = []; json['attachmentsWorkOrder'].forEach((v) { v["name"] = URLs.getFileUrl(v["name"]); - attachmentsWorkOrder.add(Attachment.fromJson(v)); + attachmentsWorkOrder!.add(Attachment.fromJson(v)); }); } equipmentStatus = json['equipmentStatus'] != null ? Lookup.fromJson(json['equipmentStatus']) : null; if (json['suppEngineerWorkOrders'] != null) { suppEngineerWorkOrders = []; json['suppEngineerWorkOrders'].forEach((v) { - suppEngineerWorkOrders.add(SuppEngineerWorkOrders.fromJson(v)); + suppEngineerWorkOrders!.add(SuppEngineerWorkOrders.fromJson(v)); }); } engSignature = json['engSignature']; @@ -135,84 +135,84 @@ class ServiceReport { assetLoan = json['assetLoan'] != null ? AssetInfo.fromJson(json['assetLoan']) : null; } - num id; - num parentWOId; - String workOrderNo; - num workOrderYear; - num workOrderSequennce; - CallRequest callRequest; - Lookup assetType; - AssignedEmployee assignedEmployee; - String visitDate; - List assistantEmployees; - SupplierDetails supplier; - String vendorTicketNumber; - String mrNumber; - List contactPersonWorkOrders; - Lookup calllastSituation; - Lookup currentSituation; - Lookup repairLocation; - Lookup reason; - Lookup serviceType; - String startofWorkTime; - String endofWorkTime; - num workingHours; - num travelingHours; - num travelingExpenses; - FaultDescription faultDescription; - List sparePartsWorkOrders; - String reviewComment; - String comment; - List attachmentsWorkOrder; - Lookup equipmentStatus; - List suppEngineerWorkOrders; - String engSignature; - Uint8List localEngSignature; - String nurseSignature; - Uint8List localNurseSignature; - WoParent woParentDto; - Lookup loanAvailablity; - AssetInfo assetLoan; - TimerModel timer = TimerModel(); + num? id; + num? parentWOId; + String? workOrderNo; + num? workOrderYear; + num? workOrderSequennce; + CallRequest? callRequest; + Lookup? assetType; + AssignedEmployee? assignedEmployee; + String? visitDate; + List? assistantEmployees; + SupplierDetails? supplier; + String? vendorTicketNumber; + String? mrNumber; + List? contactPersonWorkOrders; + Lookup? calllastSituation; + Lookup? currentSituation; + Lookup? repairLocation; + Lookup? reason; + Lookup? serviceType; + String? startofWorkTime; + String? endofWorkTime; + num? workingHours; + num? travelingHours; + num? travelingExpenses; + FaultDescription? faultDescription; + List? sparePartsWorkOrders; + String? reviewComment; + String? comment; + List? attachmentsWorkOrder; + Lookup? equipmentStatus; + List? suppEngineerWorkOrders; + String? engSignature; + Uint8List? localEngSignature; + String? nurseSignature; + Uint8List? localNurseSignature; + WoParent? woParentDto; + Lookup? loanAvailablity; + AssetInfo? assetLoan; + TimerModel? timer = TimerModel(); ServiceReport copyWith({ - num id, - num parentWOId, - String workOrderNo, - num workOrderYear, - num workOrderSequennce, - CallRequest callRequest, - Lookup assetType, - AssignedEmployee assignedEmployee, - String visitDate, - List assistantEmployees, - SupplierDetails supplier, - String vendorTicketNumber, - String mrNumber, - List contactPersonWorkOrders, - Lookup calllastSituation, - Lookup currentSituation, - Lookup repairLocation, - Lookup reason, - Lookup serviceType, - String startofWorkTime, - String endofWorkTime, - num workingHours, - num travelingHours, - num travelingExpenses, - FaultDescription faultDescription, - List sparePartsWorkOrders, - String reviewComment, - String comment, - List attachmentsWorkOrder, - Lookup equipmentStatus, - List suppEngineerWorkOrders, - String engSignature, - String nurseSignature, - WoParent woParentDto, - Lookup loanAvailablity, - AssetInfo assetLoan, - TimerModel timer, + num? id, + num? parentWOId, + String? workOrderNo, + num? workOrderYear, + num? workOrderSequennce, + CallRequest? callRequest, + Lookup? assetType, + AssignedEmployee? assignedEmployee, + String? visitDate, + List? assistantEmployees, + SupplierDetails? supplier, + String? vendorTicketNumber, + String? mrNumber, + List? contactPersonWorkOrders, + Lookup? calllastSituation, + Lookup? currentSituation, + Lookup? repairLocation, + Lookup? reason, + Lookup? serviceType, + String? startofWorkTime, + String? endofWorkTime, + num? workingHours, + num? travelingHours, + num? travelingExpenses, + FaultDescription? faultDescription, + List? sparePartsWorkOrders, + String? reviewComment, + String? comment, + List? attachmentsWorkOrder, + Lookup? equipmentStatus, + List? suppEngineerWorkOrders, + String? engSignature, + String? nurseSignature, + WoParent? woParentDto, + Lookup? loanAvailablity, + AssetInfo? assetLoan, + TimerModel? timer, }) => ServiceReport( id: id ?? this.id, @@ -262,73 +262,73 @@ class ServiceReport { map['workOrderYear'] = workOrderYear; map['workOrderSequennce'] = workOrderSequennce; if (callRequest != null) { - map['callRequest'] = callRequest.toJson(); + map['callRequest'] = callRequest!.toJson(); } if (assetType != null) { - map['assetType'] = assetType.toJson(); + map['assetType'] = assetType!.toJson(); } if (assignedEmployee != null) { - map['assignedEmployee'] = assignedEmployee.toJson(); + map['assignedEmployee'] = assignedEmployee!.toJson(); } map['visitDate'] = visitDate; if (assistantEmployees != null) { - map['assistantEmployees'] = assistantEmployees.map((v) => v.toJson()).toList(); + map['assistantEmployees'] = assistantEmployees!.map((v) => v.toJson()).toList(); } if (supplier != null) { - map['supplier'] = supplier.toJson(); + map['supplier'] = supplier!.toJson(); } map['vendorTicketNumber'] = vendorTicketNumber; map['mrNumber'] = mrNumber; if (contactPersonWorkOrders != null) { - map['contactPersonWorkOrders'] = contactPersonWorkOrders.map((v) => v.toJson()).toList(); + map['contactPersonWorkOrders'] = contactPersonWorkOrders!.map((v) => v.toJson()).toList(); } if (calllastSituation != null) { - map['calllastSituation'] = calllastSituation.toJson(); + map['calllastSituation'] = calllastSituation!.toJson(); } if (currentSituation != null) { - map['currentSituation'] = currentSituation.toJson(); + map['currentSituation'] = currentSituation!.toJson(); } if (repairLocation != null) { - map['repairLocation'] = repairLocation.toJson(); + map['repairLocation'] = repairLocation!.toJson(); } if (reason != null) { - map['reason'] = reason.toJson(); + map['reason'] = reason!.toJson(); } if (serviceType != null) { - map['serviceType'] = serviceType.toJson(); + map['serviceType'] = serviceType!.toJson(); } - map['startofWorkTime'] = timer.startAt.toString(); - map['endofWorkTime'] = timer.endAt.toString(); + map['startofWorkTime'] = timer?.startAt?.toString(); + map['endofWorkTime'] = timer?.endAt?.toString(); map['workingHours'] = workingHours; map['travelingHours'] = travelingHours; map['travelingExpenses'] = travelingExpenses; if (faultDescription != null) { - map['faultDescription'] = faultDescription.toJson(); + map['faultDescription'] = faultDescription!.toJson(); } if (sparePartsWorkOrders != null) { - map['sparePartsWorkOrders'] = sparePartsWorkOrders.map((v) => v.toJson()).toList(); + map['sparePartsWorkOrders'] = sparePartsWorkOrders!.map((v) => v.toJson()).toList(); } map['reviewComment'] = reviewComment; map['comment'] = comment; if (attachmentsWorkOrder != null) { - map['attachmentsWorkOrder'] = attachmentsWorkOrder.map((v) => {"name": v.name.getFileName}).toList(); + map['attachmentsWorkOrder'] = attachmentsWorkOrder!.map((v) => {"name": v.name.getFileName}).toList(); } if (equipmentStatus != null) { - map['equipmentStatus'] = equipmentStatus.toJson(); + map['equipmentStatus'] = equipmentStatus!.toJson(); } if (suppEngineerWorkOrders != null) { - map['suppEngineerWorkOrders'] = suppEngineerWorkOrders.map((v) => v.toJson()).toList(); + map['suppEngineerWorkOrders'] = suppEngineerWorkOrders!.map((v) => v.toJson()).toList(); } map['engSignature'] = engSignature; map['nurseSignature'] = nurseSignature; if (woParentDto != null) { - map['woParentDto'] = woParentDto.toJson(); + map['woParentDto'] = woParentDto!.toJson(); } if (loanAvailablity != null) { - map['loanAvailablity'] = loanAvailablity.toJson(); + map['loanAvailablity'] = loanAvailablity!.toJson(); } if (assetLoan != null) { - map['assetLoan'] = assetLoan.toJson(); + map['assetLoan'] = assetLoan!.toJson(); } return map; } diff --git a/lib/models/service_request/service_request.dart b/lib/models/service_request/service_request.dart index 67fadb61..df4b7193 100644 --- a/lib/models/service_request/service_request.dart +++ b/lib/models/service_request/service_request.dart @@ -7,50 +7,50 @@ import 'package:test_sa/models/fault_description.dart'; import 'package:test_sa/models/lookup.dart'; class ServiceRequest { - String id; - String requestCode; - - CallCreatedBy callCreatedBy; - String deviceSerialNumber; - int deviceId; - String deviceArName; - String deviceEnName; - List devicePhotos; - String callComments; - String hospitalName; - int hospitalId; - String departmentName; - String engineerName; - String engineerId; - String date; - String audio; - int statusValue; - int statusId; - String statusLabel; - String reviewComment; - String comments; + String? id; + String? requestCode; + + CallCreatedBy? callCreatedBy; + String? deviceSerialNumber; + int? deviceId; + String? deviceArName; + String? deviceEnName; + List? devicePhotos; + String? callComments; + String? hospitalName; + int? hospitalId; + String? departmentName; + String? engineerName; + String? engineerId; + String? date; + String? audio; + int? statusValue; + int? statusId; + String? statusLabel; + String? reviewComment; + String? comments; bool viewReport; - String engineerMobile; - String deviceModel; - FaultDescription faultDescription; - - //String workPerformed; - String visitDate; - String startDate; - String endDate; - String workingHours; - DateTime nextVisitDate; - String jobSheetNumber; - int reportID; - String deviceNumber; - Lookup priority; - Lookup defectType; - Lookup type; - Lookup requestedThrough; - Lookup firstAction; - Lookup loanAvailability; - Asset device; + String? engineerMobile; + String? deviceModel; + FaultDescription? faultDescription; + + //String? workPerformed; + String? visitDate; + String? startDate; + String? endDate; + String? workingHours; + DateTime? nextVisitDate; + String? jobSheetNumber; + int? reportID; + String? deviceNumber; + Lookup? priority; + Lookup? defectType; + Lookup? type; + Lookup? requestedThrough; + Lookup? firstAction; + Lookup? loanAvailability; + Asset? device; ServiceRequest({ this.id, @@ -100,7 +100,7 @@ class ServiceRequest { List images = []; if (parsedJson["attachmentsCallRequest"] != null) if (parsedJson["attachmentsCallRequest"] is List) { List list = parsedJson["attachmentsCallRequest"]; - images = list.map((e) => URLs.getFileUrl(e["name"])).toList(); + images = list.map((e) => URLs.getFileUrl(e["name"]!) as String).toList(); } // print(parsedJson["requestedDate"]??""); @@ -141,11 +141,7 @@ class ServiceRequest { jobSheetNumber: parsedJson["workOrder"] != null ? parsedJson["workOrder"]["jobSheetNumber"] : null, visitDate: DateTime.tryParse(parsedJson["visitDate"] ?? "").toString().split(" ").first, startDate: parsedJson["startDate"] == null ? null : DateTime.tryParse(parsedJson["startDate"] ?? "").toString().split(" ").first, - endDate: - - parsedJson["endDate"] == null ? null : - - DateTime.tryParse(parsedJson["endDate"] ?? "").toString().split(" ").first, + endDate: parsedJson["endDate"] == null ? null : DateTime.tryParse(parsedJson["endDate"] ?? "").toString().split(" ").first, workingHours: parsedJson["workingHours"], @@ -187,8 +183,8 @@ class ServiceRequest { } class CallCreatedBy { - String id; - String name; + String? id; + String? name; CallCreatedBy({this.id, this.name}); diff --git a/lib/models/service_request/service_request_search.dart b/lib/models/service_request/service_request_search.dart index 19dc1d47..543a4e37 100644 --- a/lib/models/service_request/service_request_search.dart +++ b/lib/models/service_request/service_request_search.dart @@ -4,17 +4,17 @@ import 'package:test_sa/models/lookup.dart'; import '../new_models/assigned_employee.dart'; class ServiceRequestSearch { - String callId; - String deviceSerialNumber; - String deviceNumber; - String deviceName; - Hospital hospital; - String model; - Lookup statusValue; - bool mostRecent; - String from, to; - Lookup dateOperator; - AssignedEmployee assignedEmployee; + String? callId; + String? deviceSerialNumber; + String? deviceNumber; + String? deviceName; + Hospital? hospital; + String? model; + Lookup? statusValue; + bool? mostRecent; + String? from, to; + Lookup? dateOperator; + AssignedEmployee? assignedEmployee; ServiceRequestSearch({ this.deviceSerialNumber, @@ -47,7 +47,7 @@ class ServiceRequestSearch { Map toMap() { Map search = {}; - if (deviceSerialNumber != null && deviceSerialNumber.isNotEmpty) { + if (deviceSerialNumber != null && deviceSerialNumber!.isNotEmpty) { search["assetSerialNumber"] = deviceSerialNumber; } @@ -55,39 +55,39 @@ class ServiceRequestSearch { search["mostRecent"] = mostRecent; } - if (deviceNumber != null && deviceNumber.isNotEmpty) { + if (deviceNumber != null && deviceNumber!.isNotEmpty) { search["assetNo"] = deviceNumber; } if (statusValue != null) { - search["status"] = statusValue.toJson(); + search["status"] = statusValue!.toJson(); } - if (deviceName != null && deviceName.isNotEmpty) { + if (deviceName != null && deviceName!.isNotEmpty) { search["assetName"] = deviceName; } if (hospital != null) { - search["site"] = hospital.name; + search["site"] = hospital!.name; } - if (model != null && model.isNotEmpty) { + if (model != null && model!.isNotEmpty) { search["modelDefinition"] = model; } - if (callId != null && callId.isNotEmpty) { + if (callId != null && callId!.isNotEmpty) { search["callId"] = callId; } if (dateOperator != null && from != null) { - search["requestedDateSymbol"] = dateOperator.toJson(); + search["requestedDateSymbol"] = dateOperator!.toJson(); search["requestedDateFrom"] = from; } if (dateOperator != null && to != null) { search["requestedDateTo"] = to; } if (assignedEmployee != null) { - search["assignedEmployee"] = assignedEmployee.toJson(); + search["assignedEmployee"] = assignedEmployee!.toJson(); } return search; } diff --git a/lib/models/service_request/spare_parts.dart b/lib/models/service_request/spare_parts.dart index 6332836c..3e064815 100644 --- a/lib/models/service_request/spare_parts.dart +++ b/lib/models/service_request/spare_parts.dart @@ -1,13 +1,7 @@ import '../base.dart'; class SparePartsWorkOrders extends Base { - SparePartsWorkOrders({ - this.id, - this.sparePart, - this.qty, - this.returnQty, - this.installQty, - }) : super(identifier: id?.toString(), name: sparePart?.partName); + SparePartsWorkOrders({this.id, this.sparePart, this.qty, this.returnQty, this.installQty}) : super(identifier: id?.toString(), name: sparePart?.partName); SparePartsWorkOrders.fromJson(dynamic json) { id = json['id']; @@ -17,32 +11,20 @@ class SparePartsWorkOrders extends Base { installQty = json['installQty']; } - num id; - SparePart sparePart; - num qty; - num returnQty; - num installQty; + num? id; + SparePart? sparePart; + num? qty; + num? returnQty; + num? installQty; - SparePartsWorkOrders copyWith({ - num id, - SparePart sparePart, - num qty, - num returnQty, - num installQty, - }) => - SparePartsWorkOrders( - id: id ?? this.id, - sparePart: sparePart ?? this.sparePart, - qty: qty ?? this.qty, - returnQty: returnQty ?? this.returnQty, - installQty: installQty ?? this.installQty, - ); + SparePartsWorkOrders copyWith({num? id, SparePart? sparePart, num? qty, num? returnQty, num? installQty}) => + SparePartsWorkOrders(id: id ?? this.id, sparePart: sparePart ?? this.sparePart, qty: qty ?? this.qty, returnQty: returnQty ?? this.returnQty, installQty: installQty ?? this.installQty); Map toJson() { final map = {}; map['id'] = id; if (sparePart != null) { - map['sparePart'] = sparePart.toJson(); + map['sparePart'] = sparePart!.toJson(); } map['qty'] = qty ?? 0; map['returnQty'] = returnQty; @@ -68,23 +50,13 @@ class SparePart extends Base { assetId = json['assetId']; } - num id; - String partNo; - String partName; - num assetId; + num? id; + String? partNo; + String? partName; + num? assetId; - SparePart copyWith({ - num id, - String partNo, - String partName, - num assetId, - }) => - SparePart( - id: id ?? this.id, - partNo: partNo ?? this.partNo, - partName: partName ?? this.partName, - assetId: assetId ?? this.assetId, - ); + SparePart copyWith({num? id, String? partNo, String? partName, num? assetId}) => + SparePart(id: id ?? this.id, partNo: partNo ?? this.partNo, partName: partName ?? this.partName, assetId: assetId ?? this.assetId); Map toJson() { final map = {}; diff --git a/lib/models/service_request/supp_engineer_work_orders.dart b/lib/models/service_request/supp_engineer_work_orders.dart index ebe3e717..780846cd 100644 --- a/lib/models/service_request/supp_engineer_work_orders.dart +++ b/lib/models/service_request/supp_engineer_work_orders.dart @@ -1,15 +1,7 @@ import 'package:test_sa/models/base.dart'; class SuppEngineerWorkOrders extends Base { - SuppEngineerWorkOrders({ - this.id, - this.supplierContactId, - this.personName, - this.personRoleName, - this.contact, - this.externalEngCode, - this.email, - }) : super(identifier: id?.toString(), name: personName); + SuppEngineerWorkOrders({this.id, this.supplierContactId, this.personName, this.personRoleName, this.contact, this.externalEngCode, this.email}) : super(identifier: id?.toString(), name: personName); SuppEngineerWorkOrders.fromJson(dynamic json) { id = json['id']; @@ -23,24 +15,15 @@ class SuppEngineerWorkOrders extends Base { email = json['email']; } - num id; - num supplierContactId; - String personName; - String personRoleName; - String contact; - String externalEngCode; - String email; + num? id; + num? supplierContactId; + String? personName; + String? personRoleName; + String? contact; + String? externalEngCode; + String? email; - SuppEngineerWorkOrders copyWith({ - num id, - num supplierContactId, - String personName, - String personRoleName, - String contact, - String externalEngCode, - String email, - }) => - SuppEngineerWorkOrders( + SuppEngineerWorkOrders copyWith({num? id, num? supplierContactId, String? personName, String? personRoleName, String? contact, String? externalEngCode, String? email}) => SuppEngineerWorkOrders( id: id ?? this.id, supplierContactId: supplierContactId ?? this.supplierContactId, personName: personName ?? this.personName, diff --git a/lib/models/service_request/supplier_details.dart b/lib/models/service_request/supplier_details.dart index 7002d34c..dfdcbf85 100644 --- a/lib/models/service_request/supplier_details.dart +++ b/lib/models/service_request/supplier_details.dart @@ -42,81 +42,81 @@ class SupplierDetails extends Base { if (json['telephones'] != null) { telephones = []; json['telephones'].forEach((v) { - telephones.add(Telephones.fromJson(v)); + telephones!.add(Telephones.fromJson(v)); }); } if (json['faxes'] != null) { faxes = []; json['faxes'].forEach((v) { - faxes.add(Faxes.fromJson(v)); + faxes!.add(Faxes.fromJson(v)); }); } if (json['addresses'] != null) { addresses = []; json['addresses'].forEach((v) { - addresses.add(Addresses.fromJson(v)); + addresses!.add(Addresses.fromJson(v)); }); } if (json['attachments'] != null) { attachments = []; json['attachments'].forEach((v) { - attachments.add(Attachments.fromJson(v)); + attachments!.add(Attachments.fromJson(v)); }); } if (json['suppPersons'] != null) { suppPersons = []; json['suppPersons'].forEach((v) { - suppPersons.add(SuppPersons.fromJson(v)); + suppPersons!.add(SuppPersons.fromJson(v)); }); } if (json['suppTCodes'] != null) { suppTCodes = []; json['suppTCodes'].forEach((v) { - suppTCodes.add(SuppTCodes.fromJson(v)); + suppTCodes!.add(SuppTCodes.fromJson(v)); }); } } - num id; - String suppliername; - String nameX; - String website; - String email; - String code; - num suppNo; - num suppStatusId; - num cityId; - String person; - String comment; - num zipcode; - String contact; - List telephones; - List faxes; - List addresses; - List attachments; - List suppPersons; - List suppTCodes; + num? id; + String? suppliername; + String? nameX; + String? website; + String? email; + String? code; + num? suppNo; + num? suppStatusId; + num? cityId; + String? person; + String? comment; + num? zipcode; + String? contact; + List? telephones; + List? faxes; + List? addresses; + List? attachments; + List? suppPersons; + List? suppTCodes; SupplierDetails copyWith({ - num id, - String suppliername, - String nameX, - String website, - String email, - String code, - num suppNo, - num suppStatusId, - num cityId, - String person, - String comment, - num zipcode, - String contact, - List telephones, - List faxes, - List addresses, - List attachments, - List suppPersons, - List suppTCodes, + num? id, + String? suppliername, + String? nameX, + String? website, + String? email, + String? code, + num? suppNo, + num? suppStatusId, + num? cityId, + String? person, + String? comment, + num? zipcode, + String? contact, + List? telephones, + List? faxes, + List? addresses, + List? attachments, + List? suppPersons, + List? suppTCodes, }) => SupplierDetails( id: id ?? this.id, @@ -156,22 +156,22 @@ class SupplierDetails extends Base { map['zipcode'] = zipcode; map['contact'] = contact; if (telephones != null) { - map['telephones'] = telephones.map((v) => v.toJson()).toList(); + map['telephones'] = telephones!.map((v) => v.toJson()).toList(); } if (faxes != null) { - map['faxes'] = faxes.map((v) => v.toJson()).toList(); + map['faxes'] = faxes!.map((v) => v.toJson()).toList(); } if (addresses != null) { - map['addresses'] = addresses.map((v) => v.toJson()).toList(); + map['addresses'] = addresses!.map((v) => v.toJson()).toList(); } if (attachments != null) { - map['attachments'] = attachments.map((v) => v.toJson()).toList(); + map['attachments'] = attachments!.map((v) => v.toJson()).toList(); } if (suppPersons != null) { - map['suppPersons'] = suppPersons.map((v) => v.toJson()).toList(); + map['suppPersons'] = suppPersons!.map((v) => v.toJson()).toList(); } if (suppTCodes != null) { - map['suppTCodes'] = suppTCodes.map((v) => v.toJson()).toList(); + map['suppTCodes'] = suppTCodes!.map((v) => v.toJson()).toList(); } return map; } @@ -192,16 +192,16 @@ class SuppTCodes { codeValue = json['codeValue']; } - num id; - num supplierId; - num codeTypeId; - String codeValue; + num? id; + num? supplierId; + num? codeTypeId; + String? codeValue; SuppTCodes copyWith({ - num id, - num supplierId, - num codeTypeId, - String codeValue, + num? id, + num? supplierId, + num? codeTypeId, + String? codeValue, }) => SuppTCodes( id: id ?? this.id, @@ -243,22 +243,22 @@ class SuppPersons extends Base { email = json['email']; } - num id; - num supplierId; - String personName; - num personRoleId; - String contact; - String externalEngCode; - String email; + num? id; + num? supplierId; + String? personName; + num? personRoleId; + String? contact; + String? externalEngCode; + String? email; SuppPersons copyWith({ - num id, - num supplierId, - String personName, - num personRoleId, - String contact, - String externalEngCode, - String email, + num? id, + num? supplierId, + String? personName, + num? personRoleId, + String? contact, + String? externalEngCode, + String? email, }) => SuppPersons( id: id ?? this.id, @@ -298,16 +298,16 @@ class Attachments { attachmentURL = json['attachmentURL']; } - num id; - num supplierId; - String attachmentName; - String attachmentURL; + num? id; + num? supplierId; + String? attachmentName; + String? attachmentURL; Attachments copyWith({ - num id, - num supplierId, - String attachmentName, - String attachmentURL, + num? id, + num? supplierId, + String? attachmentName, + String? attachmentURL, }) => Attachments( id: id ?? this.id, @@ -339,14 +339,14 @@ class Addresses { address = json['address']; } - num id; - num supplierId; - String address; + num? id; + num? supplierId; + String? address; Addresses copyWith({ - num id, - num supplierId, - String address, + num? id, + num? supplierId, + String? address, }) => Addresses( id: id ?? this.id, @@ -376,14 +376,14 @@ class Faxes { fax = json['fax']; } - num id; - num supplierId; - String fax; + num? id; + num? supplierId; + String? fax; Faxes copyWith({ - num id, - num supplierId, - String fax, + num? id, + num? supplierId, + String? fax, }) => Faxes( id: id ?? this.id, @@ -413,14 +413,14 @@ class Telephones { telephone = json['telephone']; } - num id; - num supplierId; - String telephone; + num? id; + num? supplierId; + String? telephone; Telephones copyWith({ - num id, - num supplierId, - String telephone, + num? id, + num? supplierId, + String? telephone, }) => Telephones( id: id ?? this.id, diff --git a/lib/models/service_request/supplier_engineer_model.dart b/lib/models/service_request/supplier_engineer_model.dart index f2e6838d..d46d3f2b 100644 --- a/lib/models/service_request/supplier_engineer_model.dart +++ b/lib/models/service_request/supplier_engineer_model.dart @@ -1,10 +1,10 @@ class SupplierEngineer { - int id; - int supplierId; - String personName; - int personRoleId; - String contact; - String email; + int? id; + int? supplierId; + String? personName; + int? personRoleId; + String? contact; + String? email; SupplierEngineer({this.id, this.supplierId, this.personName, this.personRoleId, this.contact, this.email}); diff --git a/lib/models/service_request/wo_call_request.dart b/lib/models/service_request/wo_call_request.dart index 5c47648b..8de2b94c 100644 --- a/lib/models/service_request/wo_call_request.dart +++ b/lib/models/service_request/wo_call_request.dart @@ -30,7 +30,7 @@ class CallRequest { if (json['callSiteContactPerson'] != null) { callSiteContactPerson = []; json['callSiteContactPerson'].forEach((v) { - callSiteContactPerson.add(CallSiteContactPerson.fromJson(v)); + callSiteContactPerson!.add(CallSiteContactPerson.fromJson(v)); }); } status = json['status'] != null ? Lookup.fromJson(json['status']) : null; @@ -42,34 +42,34 @@ class CallRequest { assetType = json['assetType']; } - num id; - String callNo; - String callComments; - Asset asset; - AssignedEmployee assignedEmployee; - List callSiteContactPerson; - Lookup status; - Lookup callLastSituation; - Lookup defectType; - Lookup firstAction; - Lookup loanAvailablity; - AssetInfo assetLoan; - num assetType; + num? id; + String? callNo; + String? callComments; + Asset? asset; + AssignedEmployee? assignedEmployee; + List? callSiteContactPerson; + Lookup? status; + Lookup? callLastSituation; + Lookup? defectType; + Lookup? firstAction; + Lookup? loanAvailablity; + AssetInfo? assetLoan; + num? assetType; CallRequest copyWith({ - num id, - String callNo, - String callComments, - Asset asset, - AssignedEmployee assignedEmployee, - List callSiteContactPerson, - Lookup status, - Lookup callLastSituation, - Lookup defectType, - Lookup firstAction, - Lookup loanAvailablity, - AssetInfo assetLoan, - num assetType, + num? id, + String? callNo, + String? callComments, + Asset? asset, + AssignedEmployee? assignedEmployee, + List? callSiteContactPerson, + Lookup? status, + Lookup? callLastSituation, + Lookup? defectType, + Lookup? firstAction, + Lookup? loanAvailablity, + AssetInfo? assetLoan, + num? assetType, }) => CallRequest( id: id ?? this.id, @@ -93,31 +93,31 @@ class CallRequest { map['callNo'] = callNo; map['callComments'] = callComments; if (asset != null) { - map['asset'] = asset.toJson(); + map['asset'] = asset!.toJson(); } if (assignedEmployee != null) { - map['assignedEmployee'] = assignedEmployee.toJson(); + map['assignedEmployee'] = assignedEmployee!.toJson(); } if (callSiteContactPerson != null) { - map['callSiteContactPerson'] = callSiteContactPerson.map((v) => v.toJson()).toList(); + map['callSiteContactPerson'] = callSiteContactPerson!.map((v) => v.toJson()).toList(); } if (status != null) { - map['status'] = status.toJson(); + map['status'] = status!.toJson(); } if (callLastSituation != null) { - map['callLastSituation'] = callLastSituation.toJson(); + map['callLastSituation'] = callLastSituation!.toJson(); } if (defectType != null) { - map['defectType'] = defectType.toJson(); + map['defectType'] = defectType!.toJson(); } if (firstAction != null) { - map['firstAction'] = firstAction.toJson(); + map['firstAction'] = firstAction!.toJson(); } if (loanAvailablity != null) { - map['loanAvailablity'] = loanAvailablity.toJson(); + map['loanAvailablity'] = loanAvailablity!.toJson(); } if (assetLoan != null) { - map['assetLoan'] = assetLoan.toJson(); + map['assetLoan'] = assetLoan!.toJson(); } map['assetType'] = assetType; return map; diff --git a/lib/models/service_request/wo_parent.dart b/lib/models/service_request/wo_parent.dart index 37cdf467..0207670f 100644 --- a/lib/models/service_request/wo_parent.dart +++ b/lib/models/service_request/wo_parent.dart @@ -28,35 +28,35 @@ class WoParent { if (json['suppEngineerWorkOrders'] != null) { suppEngineerWorkOrders = []; json['suppEngineerWorkOrders'].forEach((v) { - suppEngineerWorkOrders.add(SuppEngineerWorkOrders.fromJson(v)); + suppEngineerWorkOrders!.add(SuppEngineerWorkOrders.fromJson(v)); }); } equipmentStatus = json['equipmentStatus'] != null ? Lookup.fromJson(json['equipmentStatus']) : null; currentSituation = json['currentSituation'] != null ? Lookup.fromJson(json['currentSituation']) : null; } - Lookup callLastSituation; - SupplierDetails supplier; - Lookup assetType; - String vendorTicketNumber; - num callId; - num id; - StepsWorkOrder stepsWorkOrder; - List suppEngineerWorkOrders; - Lookup equipmentStatus; - Lookup currentSituation; + Lookup? callLastSituation; + SupplierDetails? supplier; + Lookup? assetType; + String? vendorTicketNumber; + num? callId; + num? id; + StepsWorkOrder? stepsWorkOrder; + List? suppEngineerWorkOrders; + Lookup? equipmentStatus; + Lookup? currentSituation; WoParent copyWith({ - Lookup callLastSituation, - SupplierDetails supplier, - Lookup assetType, - String vendorTicketNumber, - num callId, - num id, - StepsWorkOrder stepsWorkOrder, - List suppEngineerWorkOrders, - Lookup equipmentStatus, - Lookup currentSituation, + Lookup? callLastSituation, + SupplierDetails? supplier, + Lookup? assetType, + String? vendorTicketNumber, + num? callId, + num? id, + StepsWorkOrder? stepsWorkOrder, + List? suppEngineerWorkOrders, + Lookup? equipmentStatus, + Lookup? currentSituation, }) => WoParent( callLastSituation: callLastSituation ?? this.callLastSituation, @@ -74,44 +74,35 @@ class WoParent { Map toJson() { final map = {}; if (callLastSituation != null) { - map['callLastSituation'] = callLastSituation.toJson(); + map['callLastSituation'] = callLastSituation!.toJson(); } if (supplier != null) { - map['supplier'] = supplier.toJson(); + map['supplier'] = supplier!.toJson(); } if (assetType != null) { - map['assetType'] = assetType.toJson(); + map['assetType'] = assetType!.toJson(); } map['vendorTicketNumber'] = vendorTicketNumber; map['callId'] = callId; map['id'] = id; if (stepsWorkOrder != null) { - map['stepsWorkOrderDto'] = stepsWorkOrder.toJson(); + map['stepsWorkOrderDto'] = stepsWorkOrder!.toJson(); } if (suppEngineerWorkOrders != null) { - map['suppEngineerWorkOrders'] = suppEngineerWorkOrders.map((v) => v.toJson()).toList(); + map['suppEngineerWorkOrders'] = suppEngineerWorkOrders!.map((v) => v.toJson()).toList(); } if (equipmentStatus != null) { - map['equipmentStatus'] = equipmentStatus.toJson(); + map['equipmentStatus'] = equipmentStatus!.toJson(); } if (currentSituation != null) { - map['currentSituation'] = currentSituation.toJson(); + map['currentSituation'] = currentSituation!.toJson(); } return map; } } class StepsWorkOrder { - StepsWorkOrder({ - this.sequence, - this.id, - this.name, - this.statusValue, - this.typeTransaction, - this.processed, - this.parentWOId, - this.callId, - }); + StepsWorkOrder({this.sequence, this.id, this.name, this.statusValue, this.typeTransaction, this.processed, this.parentWOId, this.callId}); StepsWorkOrder.fromJson(dynamic json) { sequence = json['sequence']; @@ -124,24 +115,24 @@ class StepsWorkOrder { callId = json['callId']; } - num sequence; - num id; - String name; - num statusValue; - String typeTransaction; - bool processed; - num parentWOId; - num callId; + num? sequence; + num? id; + String? name; + num? statusValue; + String? typeTransaction; + bool? processed; + num? parentWOId; + num? callId; StepsWorkOrder copyWith({ - num sequence, - num id, - String name, - num statusValue, - String typeTransaction, - bool processed, - num parentWOId, - num callId, + num? sequence, + num? id, + String? name, + num? statusValue, + String? typeTransaction, + bool? processed, + num? parentWOId, + num? callId, }) => StepsWorkOrder( sequence: sequence ?? this.sequence, diff --git a/lib/models/subtitle.dart b/lib/models/subtitle.dart index a8932182..95163d94 100644 --- a/lib/models/subtitle.dart +++ b/lib/models/subtitle.dart @@ -252,210 +252,210 @@ // } // // Subtitle({ -// @required this.updateServiceRequest, -// @required this.comment, -// @required this.currentlyServiceNotAvailable, -// @required this.waitUntilYourRequestComplete, -// @required this.requestCompleteSuccessfully, -// @required this.failedToCompleteRequest, -// @required this.update, -// @required this.cancel, -// @required this.confirm, -// @required this.exit, -// @required this.exitAlert, -// @required this.signOutAlert, -// @required this.language, -// @required this.name, -// @required this.email, -// @required this.phoneNumber, -// @required this.password, -// @required this.forgetPassword, -// @required this.confirmPassword, -// @required this.signIn, -// @required this.signUp, -// @required this.nameValidateMessage, -// @required this.emailValidateMessage, -// @required this.phoneNumberValidateMessage, -// @required this.passwordValidateMessage, -// @required this.confirmPasswordValidateMessage, -// @required this.emailExist, -// @required this.forgetPasswordWithMark, -// @required this.phoneNumberExist, -// @required this.showPassword, -// @required this.signOut, -// @required this.wrongEmailOrPassword, -// @required this.next, -// @required this.back, -// @required this.search, -// @required this.searchByName, -// @required this.address, -// @required this.description, -// @required this.title, -// @required this.addressNotFound, -// @required this.addressValidateMessage, -// @required this.dataNotFound, -// @required this.descriptionNotFound, -// @required this.descriptionValidateMessage, -// @required this.edit, -// @required this.emailNotFound, -// @required this.from, -// @required this.linkNotFound, -// @required this.nameNotFound, -// @required this.phoneNumberNotFound, -// @required this.titleNotFound, -// @required this.titleValidateMessage, -// @required this.to, -// @required this.urlNotFound, -// @required this.nameExist, -// @required this.unitRequired, -// @required this.unite, -// @required this.hospitalRequired, -// @required this.whatsApp, -// @required this.submit, -// @required this.shareAntherIssue, -// @required this.reportIssue, -// @required this.noUniteFound, -// @required this.pickUnite, -// @required this.noHospitalFound, -// @required this.pickHospital, -// @required this.shareApp, -// @required this.ourWebsite, -// @required this.linkedIn, -// @required this.facebook, -// @required this.hotLine, -// @required this.trackServiceRequest, -// @required this.newServiceRequest, -// @required this.deviceModel, -// @required this.noServiceRequestFound, -// @required this.engineerName, -// @required this.serviceRequests, -// @required this.jobSheetNumber, -// @required this.visitDate, -// @required this.workPerformed, -// @required this.faultDescription, -// @required this.serviceRequestInformation, -// @required this.maintenanceIssue, -// @required this.deviceArName, -// @required this.hospital, -// @required this.status, -// @required this.date, -// @required this.engineerPhone, -// @required this.device, -// @required this.deviceSN, -// @required this.details, -// @required this.requestInformation, -// @required this.model, -// @required this.brand, -// @required this.noDeviceFound, -// @required this.noDateFound, -// @required this.searchBySn, -// @required this.pickDevice, -// @required this.notifications, -// @required this.notificationsNotFound, -// @required this.twitter, -// @required this.add, -// @required this.code, -// @required this.deviceName, -// @required this.serialNumber, -// @required this.policy, -// @required this.clearSearch, -// @required this.closed, -// @required this.create, -// @required this.createServiceRequest, -// @required this.delete, -// @required this.deviceImages, -// @required this.deviceFiles, -// @required this.deviceRequired, -// @required this.general, -// @required this.maintenanceIssueRequired, -// @required this.maxImagesNumberIs5, -// @required this.newWord, -// @required this.noModelFound, -// @required this.noSnFound, -// @required this.reason1, -// @required this.reason2, -// @required this.reason3, -// @required this.reason4, -// @required this.reason5, -// @required this.repaired, -// @required this.repeated, -// @required this.sn, -// @required this.underRepair, -// @required this.actualDate, -// @required this.expectDate, -// @required this.visitInformation, -// @required this.regularVisitsUpdatedSuccessfully, -// @required this.regularVisits, -// @required this.updateRegularVisits, -// @required this.updatingDots, -// @required this.preventiveMaintenanceUpdatedSuccessfully, -// @required this.updatePreventiveMaintenance, -// @required this.preventiveMaintenance, -// @required this.requiredStatus, -// @required this.noSerialNumberFound, -// @required this.updateVisitsGroup, -// @required this.pickFromGallery, -// @required this.pickFromCamera, -// @required this.images, -// @required this.done, -// @required this.imagesRequired, -// @required this.notYet, -// @required this.noVisitsFound, -// @required this.onHold, -// @required this.nextVisitDate, -// @required this.contactStatus, -// @required this.travelingHours, -// @required this.workingHours, -// @required this.taskStatus, -// @required this.image, -// @required this.pickImage, -// @required this.requiredImage, -// @required this.requiredFile, -// @required this.activationAlert, -// @required this.callId, -// @required this.requiredWord, -// @required this.quantity, -// @required this.callLastSituation, -// @required this.invoiceNumber, -// @required this.invoiceCode, -// @required this.attachImage, -// @required this.customer, -// @required this.editServiceReport, -// @required this.newServiceReport, -// @required this.number, -// @required this.operatingHours, -// @required this.partNumberName, -// @required this.reasons, -// @required this.reportStatus, -// @required this.reportType, -// @required this.assetType, -// @required this.workPreformed, -// @required this.alert, -// @required this.duplicateAlert, -// @required this.duplicateAlertMessage, -// @required this.duplicateRequest, -// @required this.orderWorkNumber, -// @required this.assignedEmployee, -// @required this.assetSN, -// @required this.assetName, -// @required this.site, -// @required this.maintenanceSituation, -// @required this.currentSituation, -// @required this.repairLocation, -// @required this.travelingExpense, -// @required this.startDate, -// @required this.endDate, -// @required this.requestedQuantity, -// @required this.deliveredQuantity, -// @required this.assetNumber, -// @required this.destinationSite, -// @required this.building, -// @required this.floor, -// @required this.department, -// @required this.room, -// @required this.actions, -// @required this.pickFromFiles, -// @required this.pickFile, +// required this.updateServiceRequest, +// required this.comment, +// required this.currentlyServiceNotAvailable, +// required this.waitUntilYourRequestComplete, +// required this.requestCompleteSuccessfully, +// required this.failedToCompleteRequest, +// required this.update, +// required this.cancel, +// required this.confirm, +// required this.exit, +// required this.exitAlert, +// required this.signOutAlert, +// required this.language, +// required this.name, +// required this.email, +// required this.phoneNumber, +// required this.password, +// required this.forgetPassword, +// required this.confirmPassword, +// required this.signIn, +// required this.signUp, +// required this.nameValidateMessage, +// required this.emailValidateMessage, +// required this.phoneNumberValidateMessage, +// required this.passwordValidateMessage, +// required this.confirmPasswordValidateMessage, +// required this.emailExist, +// required this.forgetPasswordWithMark, +// required this.phoneNumberExist, +// required this.showPassword, +// required this.signOut, +// required this.wrongEmailOrPassword, +// required this.next, +// required this.back, +// required this.search, +// required this.searchByName, +// required this.address, +// required this.description, +// required this.title, +// required this.addressNotFound, +// required this.addressValidateMessage, +// required this.dataNotFound, +// required this.descriptionNotFound, +// required this.descriptionValidateMessage, +// required this.edit, +// required this.emailNotFound, +// required this.from, +// required this.linkNotFound, +// required this.nameNotFound, +// required this.phoneNumberNotFound, +// required this.titleNotFound, +// required this.titleValidateMessage, +// required this.to, +// required this.urlNotFound, +// required this.nameExist, +// required this.unitRequired, +// required this.unite, +// required this.hospitalRequired, +// required this.whatsApp, +// required this.submit, +// required this.shareAntherIssue, +// required this.reportIssue, +// required this.noUniteFound, +// required this.pickUnite, +// required this.noHospitalFound, +// required this.pickHospital, +// required this.shareApp, +// required this.ourWebsite, +// required this.linkedIn, +// required this.facebook, +// required this.hotLine, +// required this.trackServiceRequest, +// required this.newServiceRequest, +// required this.deviceModel, +// required this.noServiceRequestFound, +// required this.engineerName, +// required this.serviceRequests, +// required this.jobSheetNumber, +// required this.visitDate, +// required this.workPerformed, +// required this.faultDescription, +// required this.serviceRequestInformation, +// required this.maintenanceIssue, +// required this.deviceArName, +// required this.hospital, +// required this.status, +// required this.date, +// required this.engineerPhone, +// required this.device, +// required this.deviceSN, +// required this.details, +// required this.requestInformation, +// required this.model, +// required this.brand, +// required this.noDeviceFound, +// required this.noDateFound, +// required this.searchBySn, +// required this.pickDevice, +// required this.notifications, +// required this.notificationsNotFound, +// required this.twitter, +// required this.add, +// required this.code, +// required this.deviceName, +// required this.serialNumber, +// required this.policy, +// required this.clearSearch, +// required this.closed, +// required this.create, +// required this.createServiceRequest, +// required this.delete, +// required this.deviceImages, +// required this.deviceFiles, +// required this.deviceRequired, +// required this.general, +// required this.maintenanceIssueRequired, +// required this.maxImagesNumberIs5, +// required this.newWord, +// required this.noModelFound, +// required this.noSnFound, +// required this.reason1, +// required this.reason2, +// required this.reason3, +// required this.reason4, +// required this.reason5, +// required this.repaired, +// required this.repeated, +// required this.sn, +// required this.underRepair, +// required this.actualDate, +// required this.expectDate, +// required this.visitInformation, +// required this.regularVisitsUpdatedSuccessfully, +// required this.regularVisits, +// required this.updateRegularVisits, +// required this.updatingDots, +// required this.preventiveMaintenanceUpdatedSuccessfully, +// required this.updatePreventiveMaintenance, +// required this.preventiveMaintenance, +// required this.requiredStatus, +// required this.noSerialNumberFound, +// required this.updateVisitsGroup, +// required this.pickFromGallery, +// required this.pickFromCamera, +// required this.images, +// required this.done, +// required this.imagesRequired, +// required this.notYet, +// required this.noVisitsFound, +// required this.onHold, +// required this.nextVisitDate, +// required this.contactStatus, +// required this.travelingHours, +// required this.workingHours, +// required this.taskStatus, +// required this.image, +// required this.pickImage, +// required this.requiredImage, +// required this.requiredFile, +// required this.activationAlert, +// required this.callId, +// required this.requiredWord, +// required this.quantity, +// required this.callLastSituation, +// required this.invoiceNumber, +// required this.invoiceCode, +// required this.attachImage, +// required this.customer, +// required this.editServiceReport, +// required this.newServiceReport, +// required this.number, +// required this.operatingHours, +// required this.partNumberName, +// required this.reasons, +// required this.reportStatus, +// required this.reportType, +// required this.assetType, +// required this.workPreformed, +// required this.alert, +// required this.duplicateAlert, +// required this.duplicateAlertMessage, +// required this.duplicateRequest, +// required this.orderWorkNumber, +// required this.assignedEmployee, +// required this.assetSN, +// required this.assetName, +// required this.site, +// required this.maintenanceSituation, +// required this.currentSituation, +// required this.repairLocation, +// required this.travelingExpense, +// required this.startDate, +// required this.endDate, +// required this.requestedQuantity, +// required this.deliveredQuantity, +// required this.assetNumber, +// required this.destinationSite, +// required this.building, +// required this.floor, +// required this.department, +// required this.room, +// required this.actions, +// required this.pickFromFiles, +// required this.pickFile, // }); // // factory Subtitle.fromJson(Map parsedJson) { diff --git a/lib/new_views/app_style/app_themes.dart b/lib/new_views/app_style/app_themes.dart index d384040a..746ea308 100644 --- a/lib/new_views/app_style/app_themes.dart +++ b/lib/new_views/app_style/app_themes.dart @@ -19,8 +19,8 @@ class AppThemes { ), bottomNavigationBarTheme: BottomNavigationBarThemeData( type: BottomNavigationBarType.fixed, - unselectedLabelStyle: ThemeData.light().textTheme.bodySmall.copyWith(fontWeight: FontWeight.w500), - selectedLabelStyle: ThemeData.light().textTheme.bodySmall.copyWith(fontWeight: FontWeight.w500), + unselectedLabelStyle: ThemeData.light().textTheme.bodySmall?.copyWith(fontWeight: FontWeight.w500), + selectedLabelStyle: ThemeData.light().textTheme.bodySmall?.copyWith(fontWeight: FontWeight.w500), selectedItemColor: AppColor.primary70, unselectedItemColor: AppColor.neutral20, backgroundColor: Colors.white, @@ -47,8 +47,8 @@ class AppThemes { ), bottomNavigationBarTheme: BottomNavigationBarThemeData( type: BottomNavigationBarType.fixed, - unselectedLabelStyle: ThemeData.dark().textTheme.bodySmall.copyWith(fontWeight: FontWeight.w500), - selectedLabelStyle: ThemeData.dark().textTheme.bodySmall.copyWith(fontWeight: FontWeight.w500), + unselectedLabelStyle: ThemeData.dark().textTheme.bodySmall?.copyWith(fontWeight: FontWeight.w500), + selectedLabelStyle: ThemeData.dark().textTheme.bodySmall?.copyWith(fontWeight: FontWeight.w500), selectedItemColor: AppColor.primary40, unselectedItemColor: AppColor.neutral10, backgroundColor: AppColor.neutral60, diff --git a/lib/new_views/common_widgets/app_bottom_nav_bar.dart b/lib/new_views/common_widgets/app_bottom_nav_bar.dart index 53d78b9f..520eff5b 100644 --- a/lib/new_views/common_widgets/app_bottom_nav_bar.dart +++ b/lib/new_views/common_widgets/app_bottom_nav_bar.dart @@ -12,11 +12,11 @@ class AppBottomNavigationBar extends StatelessWidget { final Function(int index) onPressed; final int selectedIndex; - const AppBottomNavigationBar({Key key, @required this.onPressed, @required this.selectedIndex}) : super(key: key); + const AppBottomNavigationBar({Key? key, required this.onPressed, required this.selectedIndex}) : super(key: key); @override Widget build(BuildContext context) { - bool isEngineer = (Provider.of(context, listen: false).user.type) == UsersTypes.engineer; + bool isEngineer = (Provider.of(context, listen: false).user!.type) == UsersTypes.engineer; return ClipRRect( borderRadius: const BorderRadius.only(topLeft: Radius.circular(20.0), topRight: Radius.circular(20.0)), child: Container( @@ -44,14 +44,14 @@ class AppBottomNavigationBar extends StatelessWidget { ); } - BottomNavigationBarItem navBarItem(BuildContext context, {@required int index, @required String iconName, @required String label}) { + BottomNavigationBarItem navBarItem(BuildContext context, {required int index, required String iconName, required String label}) { return BottomNavigationBarItem( icon: iconName - ?.toSvgAsset( + .toSvgAsset( width: 24, color: selectedIndex == index ? Theme.of(context).bottomNavigationBarTheme.selectedItemColor : Theme.of(context).bottomNavigationBarTheme.unselectedItemColor, ) - ?.paddingOnly(top: 10, bottom: 10), + .paddingOnly(top: 10, bottom: 10), label: label, ); } diff --git a/lib/new_views/common_widgets/app_dashed_button.dart b/lib/new_views/common_widgets/app_dashed_button.dart index 7d2a0b02..288e780a 100644 --- a/lib/new_views/common_widgets/app_dashed_button.dart +++ b/lib/new_views/common_widgets/app_dashed_button.dart @@ -11,7 +11,7 @@ class AppDashedButton extends StatelessWidget { final String title; final VoidCallback onPressed; - const AppDashedButton({@required this.title, @required this.onPressed, Key key}) : super(key: key); + const AppDashedButton({required this.title, required this.onPressed, Key? key}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/new_views/common_widgets/app_drawer.dart b/lib/new_views/common_widgets/app_drawer.dart index c78e0bf5..5ac57d57 100644 --- a/lib/new_views/common_widgets/app_drawer.dart +++ b/lib/new_views/common_widgets/app_drawer.dart @@ -16,7 +16,7 @@ import '../../views/widgets/dialogs/dialog.dart'; import '../pages/settings_page.dart'; class AppDrawer extends StatelessWidget { - const AppDrawer({Key key}) : super(key: key); + const AppDrawer({Key? key}) : super(key: key); @override Widget build(BuildContext context) { @@ -41,14 +41,10 @@ class AppDrawer extends StatelessWidget { padding: const EdgeInsets.all(1), // Border radius child: ClipOval( child: snapshot.profileImage != null - ? Image.file(snapshot.profileImage) - : (snapshot.user.profilePhotoName?.isNotEmpty ?? false) - ? Image.network(snapshot.user.profilePhotoName) - : const Icon( - Icons.person, - size: 50, - color: Colors.white, - ), + ? Image.file(snapshot.profileImage!) + : (snapshot.user!.profilePhotoName?.isNotEmpty ?? false) + ? Image.network(snapshot.user!.profilePhotoName!) + : const Icon(Icons.person, size: 50, color: Colors.white), ), ), ); @@ -62,7 +58,7 @@ class AppDrawer extends StatelessWidget { ), 8.height, (userProvider.user?.username ?? "").heading3(context).custom(fontWeight: FontWeight.w600), - if ((userProvider.user?.email ?? "").isNotEmpty) (userProvider.user?.email)?.heading6(context)?.custom(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20), + if ((userProvider.user?.email ?? "").isNotEmpty) (userProvider.user!.email!).heading6(context).custom(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20), 18.height, const Divider().defaultStyle(context), ListView( @@ -92,7 +88,6 @@ class AppDrawer extends StatelessWidget { Navigator.of(context).pop(); Navigator.of(context).pop(); Navigator.of(context).pushNamedAndRemoveUntil(LoginPage.routeName, (routes) => true); - } }), 18.height, @@ -115,7 +110,7 @@ class AppDrawer extends StatelessWidget { ); } - Widget drawerItem(String icon, String title, BuildContext context, {Color color}) { + Widget drawerItem(String icon, String title, BuildContext context, {Color? color}) { return Row( children: [ (icon ?? "").toSvgAsset(width: 24, height: 24, color: color ?? (context.isDark ? AppColor.neutral10 : AppColor.neutral20)), diff --git a/lib/new_views/common_widgets/app_filled_button.dart b/lib/new_views/common_widgets/app_filled_button.dart index a9d46b53..77045509 100644 --- a/lib/new_views/common_widgets/app_filled_button.dart +++ b/lib/new_views/common_widgets/app_filled_button.dart @@ -5,23 +5,15 @@ import 'package:test_sa/extensions/widget_extensions.dart'; import 'package:test_sa/new_views/app_style/app_color.dart'; class AppFilledButton extends StatelessWidget { - final VoidCallback onPressed; + final VoidCallback? onPressed; final String label; final bool maxWidth, loading; - final Color buttonColor; - final Color textColor; + final Color? buttonColor; + final Color? textColor; final bool showBorder; - const AppFilledButton({ - @required this.onPressed, - @required this.label, - this.maxWidth = false, - this.loading = false, - this.showBorder = false, - this.buttonColor, - this.textColor, - Key key, - }) : super(key: key); + const AppFilledButton({ this.onPressed, required this.label, this.maxWidth = false, this.loading = false, this.showBorder = false, this.buttonColor, this.textColor, Key? key}) + : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/new_views/common_widgets/app_floating_action_button.dart b/lib/new_views/common_widgets/app_floating_action_button.dart index 6f5ecebe..29f9892b 100644 --- a/lib/new_views/common_widgets/app_floating_action_button.dart +++ b/lib/new_views/common_widgets/app_floating_action_button.dart @@ -7,6 +7,7 @@ import 'package:test_sa/extensions/int_extensions.dart'; import 'package:test_sa/extensions/text_extensions.dart'; import 'package:test_sa/extensions/widget_extensions.dart'; import 'package:test_sa/models/enums/user_types.dart'; +import 'package:test_sa/models/user.dart'; import 'package:test_sa/new_views/pages/new_gas_refill_request_page.dart'; import 'package:test_sa/views/pages/device_transfer/request_device_transfer.dart'; import 'package:test_sa/views/pages/user/requests/create_service_request_page.dart'; @@ -14,7 +15,7 @@ import 'package:test_sa/views/pages/user/requests/create_service_request_page.da import '../app_style/app_color.dart'; class AppFloatingActionButton extends StatefulWidget { - const AppFloatingActionButton({Key key}) : super(key: key); + const AppFloatingActionButton({Key? key}) : super(key: key); @override State createState() => _AppFloatingActionButtonState(); @@ -35,7 +36,7 @@ class _AppFloatingActionButtonState extends State { @override Widget build(BuildContext context) { - final user = Provider.of(context, listen: false).user; + User user = Provider.of(context, listen: false).user!; final elements = [ if (user.type == UsersTypes.normal_user) fabItem(context.translation.gasRefillRequest, "gas_refill_request", NewGasRefillRequestPage.routeName), if (user.type == UsersTypes.normal_user) const Divider().defaultStyle(context).paddingOnly(top: 16, bottom: 16), @@ -102,7 +103,7 @@ class _AppFloatingActionButtonState extends State { child: iconName.toSvgAsset(width: 24, height: 24, color: AppColor.blueStatus(context)), ) ], - ).onPress(() async{ + ).onPress(() async { _rotate(); await Navigator.of(context).pushNamed(routeName); Provider.of(context, listen: false).getRequests(); diff --git a/lib/new_views/common_widgets/app_lazy_loading.dart b/lib/new_views/common_widgets/app_lazy_loading.dart index ecfb4806..d4f82cfb 100644 --- a/lib/new_views/common_widgets/app_lazy_loading.dart +++ b/lib/new_views/common_widgets/app_lazy_loading.dart @@ -4,7 +4,7 @@ import 'package:test_sa/new_views/app_style/app_color.dart'; import 'package:test_sa/views/app_style/sizing.dart'; class AppLazyLoading extends StatelessWidget { - const AppLazyLoading({Key key}) : super(key: key); + const AppLazyLoading({Key? key}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/new_views/common_widgets/app_loading_manager.dart b/lib/new_views/common_widgets/app_loading_manager.dart index 8e3882bb..7a4f70b2 100644 --- a/lib/new_views/common_widgets/app_loading_manager.dart +++ b/lib/new_views/common_widgets/app_loading_manager.dart @@ -9,19 +9,19 @@ class AppLoadingManager extends StatefulWidget { final bool isLoading; final bool isFailedLoading; final bool isNotPage; - final int progress; + final int? progress; final bool askOnBack; - final int stateCode; + final int? stateCode; final Future Function() onRefresh; final Widget child; const AppLoadingManager({ - Key key, - @required this.isLoading, - @required this.isFailedLoading, - @required this.stateCode, - @required this.onRefresh, - @required this.child, + Key? key, + required this.isLoading, + required this.isFailedLoading, + required this.onRefresh, + required this.child, + this.stateCode, this.progress, this.isNotPage = false, this.askOnBack = false, @@ -34,7 +34,7 @@ class AppLoadingManager extends StatefulWidget { class _AppLoadingManagerState extends State { @override void initState() { - if (widget.onRefresh != null && widget.stateCode == null) { + if (widget.stateCode == null) { WidgetsBinding.instance.addPostFrameCallback((timeStamp) { widget.onRefresh(); }); @@ -44,27 +44,20 @@ class _AppLoadingManagerState extends State { @override Widget build(BuildContext context) { - Widget placeHolder; - // to load data if load not start - if (widget.isLoading != true && widget.stateCode == null) { - WidgetsBinding.instance.addPostFrameCallback((timeStamp) { - widget.onRefresh(); - }); - } + Widget? placeHolder; - // if loading of still not start in loading (true or null) - // return loading widget - if (widget.isLoading != false || widget.stateCode == null) { + // if loading is still not started or in progress + if (widget.isLoading || widget.stateCode == null) { placeHolder = Container( height: 60.toScreenHeight, decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), color: context.isDark ? AppColor.neutral50 : Colors.white, ), - child: const AppLazyLoading(), + child: AppLazyLoading(), ); } else if (widget.isFailedLoading && !widget.isNotPage) { - // if failed return failed widget + // if failed, return failed widget placeHolder = Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, @@ -74,17 +67,15 @@ class _AppLoadingManagerState extends State { OutlinedButton( onPressed: widget.onRefresh, child: Text(context.translation.tryAgain), - ) + ), ], ), ); } - // if load end successfully return loaded widget + // if loading ended successfully, return loaded widget return RefreshIndicator( - onRefresh: () async { - await widget.onRefresh(); - }, + onRefresh: widget.onRefresh, child: AnimatedSwitcher( duration: const Duration(milliseconds: 400), child: placeHolder ?? widget.child, diff --git a/lib/new_views/common_widgets/app_search_field.dart b/lib/new_views/common_widgets/app_search_field.dart index 615e5506..14d12301 100644 --- a/lib/new_views/common_widgets/app_search_field.dart +++ b/lib/new_views/common_widgets/app_search_field.dart @@ -1,36 +1,36 @@ -import 'package:flutter/material.dart'; -import 'package:test_sa/extensions/context_extension.dart'; -import 'package:test_sa/new_views/app_style/app_color.dart'; - -class AppSearchField extends StatefulWidget { - final Function(String) onChanged; - final Function(String) onSubmitted; - - const AppSearchField({Key key, this.onChanged, this.onSubmitted}) : super(key: key); - - @override - State createState() => _AppSearchFieldState(); -} - -class _AppSearchFieldState extends State { - @override - Widget build(BuildContext context) { - return TextField( - onChanged: widget.onChanged, - onSubmitted: widget.onSubmitted, - decoration: InputDecoration( - prefixIcon: const Icon( - Icons.search, - color: AppColor.neutral20, - ), - hintText: context.translation.search, - hintStyle: TextStyle(fontSize: Theme.of(context).textTheme.bodySmall.fontSize), - filled: true, - fillColor: AppColor.neutral30, - border: OutlineInputBorder( - borderRadius: BorderRadius.circular(15), - borderSide: BorderSide.none, - )), - ); - } -} +// import 'package:flutter/material.dart'; +// import 'package:test_sa/extensions/context_extension.dart'; +// import 'package:test_sa/new_views/app_style/app_color.dart'; +// +// class AppSearchField extends StatefulWidget { +// final Function(String) onChanged; +// final Function(String) onSubmitted; +// +// const AppSearchField({Key? key, this.onChanged, this.onSubmitted}) : super(key: key); +// +// @override +// State createState() => _AppSearchFieldState(); +// } +// +// class _AppSearchFieldState extends State { +// @override +// Widget build(BuildContext context) { +// return TextField( +// onChanged: widget.onChanged, +// onSubmitted: widget.onSubmitted, +// decoration: InputDecoration( +// prefixIcon: const Icon( +// Icons.search, +// color: AppColor.neutral20, +// ), +// hintText: context.translation.search, +// hintStyle: TextStyle(fontSize: Theme.of(context).textTheme.bodySmall.fontSize), +// filled: true, +// fillColor: AppColor.neutral30, +// border: OutlineInputBorder( +// borderRadius: BorderRadius.circular(15), +// borderSide: BorderSide.none, +// )), +// ); +// } +// } diff --git a/lib/new_views/common_widgets/app_tab_bar.dart b/lib/new_views/common_widgets/app_tab_bar.dart index f08bbd0c..3d93c1fa 100644 --- a/lib/new_views/common_widgets/app_tab_bar.dart +++ b/lib/new_views/common_widgets/app_tab_bar.dart @@ -2,7 +2,7 @@ // import 'package:flutter/material.dart'; // // class AppTabBar extends StatelessWidget { -// const AppTabBar({Key key}) : super(key: key); +// const AppTabBar({Key? key}) : super(key: key); // // @override // Widget build(BuildContext context) { diff --git a/lib/new_views/common_widgets/app_text_form_field.dart b/lib/new_views/common_widgets/app_text_form_field.dart index 700eb011..a105cada 100644 --- a/lib/new_views/common_widgets/app_text_form_field.dart +++ b/lib/new_views/common_widgets/app_text_form_field.dart @@ -5,47 +5,47 @@ import 'package:test_sa/new_views/app_style/app_color.dart'; import 'package:test_sa/new_views/app_style/app_text_style.dart'; class AppTextFormField extends StatefulWidget { - final Function(String) onSaved; - final Function(String) validator; - final Function(String) onChange; - final bool obscureText; - final VoidCallback showPassword; - final String hintText; - final String labelText; - final TextInputType textInputType; + final Function(String)? onSaved; + final String? Function(String?)? validator; + final Function(String)? onChange; + final bool? obscureText; + final VoidCallback? showPassword; + final String? hintText; + final String? labelText; + final TextInputType? textInputType; final String initialValue; - final TextStyle style; - final TextStyle labelStyle; + final TextStyle? style; + final TextStyle? labelStyle; final bool enable; - final TextAlign textAlign; - final FocusNode node; - final Widget suffixIcon; - final Widget prefixIcon; - final IconData prefixIconData; - final int prefixIconSize; - final TextEditingController controller; - final TextInputAction textInputAction; - final VoidCallback onAction; - final Color backgroundColor; + final TextAlign? textAlign; + final FocusNode? node; + final Widget? suffixIcon; + final Widget? prefixIcon; + final IconData? prefixIconData; + final int? prefixIconSize; + final TextEditingController? controller; + final TextInputAction? textInputAction; + final VoidCallback? onAction; + final Color? backgroundColor; final bool alignLabelWithHint; final bool showShadow; - final EdgeInsets contentPadding; + final EdgeInsets? contentPadding; final bool showWithoutDecoration; - final void Function() onTap; + final VoidCallback? onTap; const AppTextFormField({ - Key key, + Key? key, this.onSaved, this.validator, this.node, this.onChange, this.labelStyle, - this.obscureText, + this.obscureText = false, // Provide default value this.showPassword, this.hintText, this.labelText, this.textInputType = TextInputType.text, - this.initialValue, + this.initialValue = "", // Provide default value this.enable = true, this.style, this.contentPadding, @@ -60,7 +60,7 @@ class AppTextFormField extends StatefulWidget { this.backgroundColor, this.showShadow = true, this.showWithoutDecoration = false, - this.alignLabelWithHint, + this.alignLabelWithHint = false, // Provide default value this.onTap, }) : super(key: key); @@ -71,18 +71,23 @@ class AppTextFormField extends StatefulWidget { class _AppTextFormFieldState extends State { @override void initState() { - if (widget.controller != null) widget.controller.text = widget.initialValue; + widget.controller?.text = widget.initialValue; // Use null-aware operator super.initState(); } @override Widget build(BuildContext context) { - final border = UnderlineInputBorder(borderSide: BorderSide.none, borderRadius: BorderRadius.circular(10)); + final border = UnderlineInputBorder( + borderSide: BorderSide.none, + borderRadius: BorderRadius.circular(10), + ); - Widget textField = TextFormField( + final textField = TextFormField( focusNode: widget.node, enabled: widget.enable, - onSaved: widget.onSaved, + onSaved: (text) { + if (widget.onSaved != null && text != null) widget.onSaved!(text); + }, initialValue: widget.controller != null ? null : widget.initialValue, validator: widget.validator, onChanged: widget.onChange, @@ -102,17 +107,17 @@ class _AppTextFormFieldState extends State { focusedBorder: border, enabledBorder: border, errorBorder: border, - contentPadding:widget.contentPadding?? EdgeInsets.symmetric(vertical: 12.toScreenHeight, horizontal: 16.toScreenWidth), + contentPadding: widget.contentPadding ?? EdgeInsets.symmetric(vertical: 12.toScreenHeight, horizontal: 16.toScreenWidth), constraints: const BoxConstraints(), suffixIconConstraints: const BoxConstraints(minWidth: 0), filled: true, fillColor: widget.backgroundColor ?? - (context.isDark && (widget.enable == false) + (context.isDark && !widget.enable ? AppColor.neutral50 - : (widget.enable == false) + : !widget.enable ? AppColor.neutral40 : AppColor.background(context)), - errorStyle: AppTextStyle.tiny.copyWith(color: context.isDark ? AppColor.red50 : AppColor.red60), + errorStyle: AppTextStyle.tiny?.copyWith(color: context.isDark ? AppColor.red50 : AppColor.red60), floatingLabelStyle: AppTextStyle.body1?.copyWith(fontWeight: FontWeight.w500, color: context.isDark ? null : AppColor.neutral20), hintText: widget.hintText ?? "", labelText: widget.labelText ?? "", @@ -122,7 +127,7 @@ class _AppTextFormFieldState extends State { ? null : Icon( widget.prefixIconData, - size: widget.prefixIconSize == null ? 20.toScreenWidth : (widget.prefixIconSize - 10).toScreenWidth, + size: widget.prefixIconSize == null ? 20.toScreenWidth : (widget.prefixIconSize! - 10).toScreenWidth, color: AppColor.neutral70, )), suffixIcon: widget.suffixIcon, diff --git a/lib/new_views/common_widgets/asset_info_card.dart b/lib/new_views/common_widgets/asset_info_card.dart index c3dde106..c3400768 100644 --- a/lib/new_views/common_widgets/asset_info_card.dart +++ b/lib/new_views/common_widgets/asset_info_card.dart @@ -7,7 +7,7 @@ import 'package:test_sa/extensions/widget_extensions.dart'; import '../../models/device/asset.dart'; class AssetInfoCard extends StatelessWidget { - const AssetInfoCard({Key key, @required this.asset}) : super(key: key); + const AssetInfoCard({Key? key, required this.asset}) : super(key: key); final Asset asset; @@ -16,7 +16,7 @@ class AssetInfoCard extends StatelessWidget { return Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - asset.modelDefinition?.assetName?.cleanupWhitespace?.capitalizeFirstOfEach?.heading5(context), + (asset.modelDefinition?.assetName?.cleanupWhitespace.capitalizeFirstOfEach ?? "").heading5(context), 8.height, "${context.translation.assetNo}: ${asset.assetNumber}".bodyText(context), "${context.translation.manufacture}: ${asset.modelDefinition?.manufacturerName}".bodyText(context), diff --git a/lib/new_views/common_widgets/custom_app_bar.dart b/lib/new_views/common_widgets/custom_app_bar.dart index 06a54551..f6a77a04 100644 --- a/lib/new_views/common_widgets/custom_app_bar.dart +++ b/lib/new_views/common_widgets/custom_app_bar.dart @@ -8,10 +8,10 @@ import '../app_style/app_color.dart'; class CustomAppBar extends StatelessWidget implements PreferredSizeWidget { final String title; - final List actions; - final double bottomCorner; + final List? actions; + final double? bottomCorner; - const CustomAppBar({this.title, this.actions, this.bottomCorner, Key key}) : super(key: key); + const CustomAppBar({required this.title, this.actions, this.bottomCorner, Key? key}) : super(key: key); @override Widget build(BuildContext context) { @@ -30,9 +30,9 @@ class CustomAppBar extends StatelessWidget implements PreferredSizeWidget { ], ), actions: actions, - shape: RoundedRectangleBorder( + shape: RoundedRectangleBorder( borderRadius: BorderRadius.vertical( - bottom: Radius.circular(bottomCorner??10), + bottom: Radius.circular(bottomCorner ?? 10), ), ), ); diff --git a/lib/new_views/common_widgets/custom_badge.dart b/lib/new_views/common_widgets/custom_badge.dart index 0ca7b9ea..ccfe2a10 100644 --- a/lib/new_views/common_widgets/custom_badge.dart +++ b/lib/new_views/common_widgets/custom_badge.dart @@ -7,9 +7,9 @@ class CustomBadge extends StatelessWidget { final Color color; // The background color of the badge. const CustomBadge({ - Key key, - @required this.child, - @required this.value, + Key? key, + required this.child, + required this.value, this.color =AppColor.red30, // Default color is red }) : super(key: key); diff --git a/lib/new_views/common_widgets/default_app_bar.dart b/lib/new_views/common_widgets/default_app_bar.dart index d846fedc..7f512369 100644 --- a/lib/new_views/common_widgets/default_app_bar.dart +++ b/lib/new_views/common_widgets/default_app_bar.dart @@ -7,10 +7,10 @@ import 'package:test_sa/extensions/widget_extensions.dart'; import '../app_style/app_color.dart'; class DefaultAppBar extends StatelessWidget implements PreferredSizeWidget { - final String title; - final List actions; + final String? title; + final List? actions; - const DefaultAppBar({this.title, this.actions, Key key}) : super(key: key); + const DefaultAppBar({this.title, this.actions, Key? key}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/new_views/common_widgets/single_item_drop_down_menu.dart b/lib/new_views/common_widgets/single_item_drop_down_menu.dart index 9f2341c2..f15bcb29 100644 --- a/lib/new_views/common_widgets/single_item_drop_down_menu.dart +++ b/lib/new_views/common_widgets/single_item_drop_down_menu.dart @@ -10,63 +10,54 @@ import 'package:test_sa/views/widgets/bottom_sheets/selection_bottom_sheet.dart' import '../../models/base.dart'; import '../app_style/app_color.dart'; -class SingleItemDropDownMenu - extends StatefulWidget { +class SingleItemDropDownMenu extends StatefulWidget { final BuildContext context; - final Function(T)? onSelect; + final Function(T?)? onSelect; // Now accepts nullable values final T? initialValue; final bool enabled; final bool showAsBottomSheet; final List staticData; final String title; final double? height; - final bool showShadow ; - final Color backgroundColor; - final bool loading; + final bool showShadow; + final Color? backgroundColor; // Now nullable + final bool? loading; // Now nullable /// To use a static data (without calling API) /// just send [NullableLoadingProvider] as generic data type and fill the [staticData] const SingleItemDropDownMenu({ Key? key, - @required this.context, - @required this.title, + this.title = "", + required this.context, this.onSelect, this.initialValue, this.enabled = true, this.height, this.showAsBottomSheet = false, - this.staticData, - this.showShadow=true, + this.staticData = const [], // Provide a default empty list + this.showShadow = true, this.backgroundColor, this.loading, }) : super(key: key); @override - State> createState() => - _SingleItemDropDownMenuState(); + State> createState() => _SingleItemDropDownMenuState(); } -class _SingleItemDropDownMenuState extends State> { +class _SingleItemDropDownMenuState extends State> { T? _selectedItem; X? provider; @override void initState() { if (X != NullableLoadingProvider) { - provider = Provider.of(widget.context); + provider = Provider.of(widget.context, listen: false); } if (widget.initialValue != null) { - final result = - (X == NullableLoadingProvider ? widget.staticData : provider.items) - ?.where((element) { - return element.identifier == widget.initialValue.identifier; - }); - if (result?.isNotEmpty ?? false) _selectedItem = result.first; - if (widget.onSelect != null && - (widget.initialValue?.identifier ?? "") != - (_selectedItem?.identifier ?? "")) { - widget.onSelect(_selectedItem); + final result = (X == NullableLoadingProvider ? widget.staticData : provider?.items)?.where((element) => element.identifier == widget.initialValue?.identifier); + if (result?.isNotEmpty ?? false) _selectedItem = result!.first as T?; + if (widget.onSelect != null && (widget.initialValue?.identifier ?? "") != (_selectedItem?.identifier ?? "")) { + widget.onSelect!(_selectedItem); // Non-null assertion after null check } } super.initState(); @@ -80,20 +71,14 @@ class _SingleItemDropDownMenuState oldWidget) { if (widget.initialValue != null) { - final result = - (X == NullableLoadingProvider ? widget.staticData : provider.items) - ?.where((element) { - return element.identifier == widget.initialValue.identifier; - }); + final result = (X == NullableLoadingProvider ? widget.staticData : provider?.items)?.where((element) => element.identifier == widget.initialValue?.identifier); if (result?.isNotEmpty ?? false) { - _selectedItem = result.first; + _selectedItem = result?.first as T?; } else { _selectedItem = null; } - if (widget.onSelect != null && - (widget.initialValue?.identifier ?? "") != - (_selectedItem?.identifier ?? "")) { - widget.onSelect(_selectedItem); + if (widget.onSelect != null && (widget.initialValue?.identifier ?? "") != (_selectedItem?.identifier ?? "")) { + widget.onSelect!(_selectedItem); // Non-null assertion after null check } } else { _selectedItem = null; @@ -103,16 +88,12 @@ class _SingleItemDropDownMenuState( value: _selectedItem, @@ -157,60 +132,55 @@ class _SingleItemDropDownMenuState>((value) { + items: ((X == NullableLoadingProvider) ? widget.staticData : provider?.items as List)?.map>((value) { return DropdownMenuItem( value: value, child: Text( - value?.name ?? "", + value?.name ?? "", // Null-aware operator for value.name style: Theme.of(context).textTheme.bodyLarge, ), ); - })?.toList(), - ).onPress(widget.showAsBottomSheet ? () async{ - - T? _selectedT = (await showModalBottomSheet( - context: context, - isScrollControlled: true, - shape: const RoundedRectangleBorder( - borderRadius: BorderRadius.vertical( - top: Radius.circular(20), - ), - ), - clipBehavior: Clip.antiAliasWithSaveLayer, - builder: (BuildContext context) => SelectionBottomSheet( - items: ((X == NullableLoadingProvider) - ? widget.staticData - : provider.items), - selectedItem: _selectedItem, - title: widget.title, - builderString: (emp) => emp?.name ?? "", - ), - )) as T?; - if(_selectedT !=null) { - widget.onSelect(_selectedT); - } - - } : null), + }).toList(), + ).onPress(widget.showAsBottomSheet + ? () async { + final _selectedT = await showModalBottomSheet( + // Specify return type + context: context, + isScrollControlled: true, + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.vertical( + top: Radius.circular(20), + ), + ), + clipBehavior: Clip.antiAliasWithSaveLayer, + builder: (BuildContext context) => SelectionBottomSheet( + // Specify generic type + items: ((X == NullableLoadingProvider) ? widget.staticData : provider?.items as List) ?? [], // Provide default empty list if null + selectedItem: _selectedItem, + title: widget.title, + builderString: (emp) => emp?.name ?? "", // Null-aware operator for emp.name + ), + ); + if (_selectedT != null) { + widget.onSelect!(_selectedT); // Non-null assertion after null check + } + } + : null), ], ), ], diff --git a/lib/new_views/common_widgets/tab_button.dart b/lib/new_views/common_widgets/tab_button.dart index 75bd44e4..625eabd8 100644 --- a/lib/new_views/common_widgets/tab_button.dart +++ b/lib/new_views/common_widgets/tab_button.dart @@ -1,7 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:badges/badges.dart' as badges; import 'package:test_sa/extensions/text_extensions.dart'; -import 'package:test_sa/extensions/widget_extensions.dart'; import 'package:test_sa/new_views/app_style/app_color.dart'; import 'package:test_sa/new_views/common_widgets/custom_badge.dart'; @@ -13,12 +11,12 @@ class TabButton extends StatelessWidget { final VoidCallback onPressed; const TabButton({ - Key key, - @required this.label, + Key? key, + required this.label, this.isSelected = false, - @required this.count, - @required this.loading = false, - @required this.onPressed, + required this.count, + this.loading = false, + required this.onPressed, }) : super(key: key); @override @@ -69,9 +67,9 @@ class TabButtonData { final VoidCallback onPressed; TabButtonData({ - @required this.label, - @required this.isSelected, - @required this.totalCount, - @required this.onPressed, + required this.label, + required this.isSelected, + required this.totalCount, + required this.onPressed, }); } diff --git a/lib/new_views/pages/help_center_page.dart b/lib/new_views/pages/help_center_page.dart index 395c1e7a..d8c78acf 100644 --- a/lib/new_views/pages/help_center_page.dart +++ b/lib/new_views/pages/help_center_page.dart @@ -8,7 +8,7 @@ import '../common_widgets/default_app_bar.dart'; class HelpCenterPage extends StatelessWidget { static const id = "/help_center_page"; - const HelpCenterPage({Key key}) : super(key: key); + const HelpCenterPage({Key? key}) : super(key: key); @override Widget build(BuildContext context) { @@ -37,7 +37,7 @@ class HelpCenterPage extends StatelessWidget { ); } - Widget buildElement(BuildContext context, {@required String title}) { + Widget buildElement(BuildContext context, {required String title}) { return Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ diff --git a/lib/new_views/pages/land_page/calendar_page.dart b/lib/new_views/pages/land_page/calendar_page.dart index 42240320..1a2c9cd2 100644 --- a/lib/new_views/pages/land_page/calendar_page.dart +++ b/lib/new_views/pages/land_page/calendar_page.dart @@ -10,14 +10,14 @@ import 'package:test_sa/new_views/pages/land_page/calender_fragments/weekly_frag import 'calender_fragments/monthly_fragment.dart'; class CalendarPage extends StatefulWidget { - const CalendarPage({Key key}) : super(key: key); + const CalendarPage({Key? key}) : super(key: key); @override State createState() => _CalendarPageState(); } class _CalendarPageState extends State with SingleTickerProviderStateMixin { - TabController _tabController; + late TabController _tabController; @override void initState() { diff --git a/lib/new_views/pages/land_page/calender_fragments/calendar_header.dart b/lib/new_views/pages/land_page/calender_fragments/calendar_header.dart index 073d98e8..fd0934e2 100644 --- a/lib/new_views/pages/land_page/calender_fragments/calendar_header.dart +++ b/lib/new_views/pages/land_page/calender_fragments/calendar_header.dart @@ -11,7 +11,7 @@ class CalendarHeader extends StatelessWidget { final DateTime dateTime; final DateFormat dateFormat; - const CalendarHeader({@required this.dateTime, @required this.dateFormat, Key key}) : super(key: key); + const CalendarHeader({required this.dateTime, required this.dateFormat, Key? key}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/new_views/pages/land_page/calender_fragments/calender_days_card.dart b/lib/new_views/pages/land_page/calender_fragments/calender_days_card.dart index 22f23647..a0d3c7b9 100644 --- a/lib/new_views/pages/land_page/calender_fragments/calender_days_card.dart +++ b/lib/new_views/pages/land_page/calender_fragments/calender_days_card.dart @@ -9,7 +9,7 @@ class CalendarDaysCard extends StatelessWidget { final String day; final bool fill; - const CalendarDaysCard({Key key, @required this.day, this.fill = false}) : super(key: key); + const CalendarDaysCard({Key? key, required this.day, this.fill = false}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/new_views/pages/land_page/calender_fragments/daily_fragment.dart b/lib/new_views/pages/land_page/calender_fragments/daily_fragment.dart index c6c53064..3f0777f8 100644 --- a/lib/new_views/pages/land_page/calender_fragments/daily_fragment.dart +++ b/lib/new_views/pages/land_page/calender_fragments/daily_fragment.dart @@ -14,7 +14,7 @@ import '../requests/ppm_item_view.dart'; import '../requests/service_request_item_view.dart'; class DailyFragment extends StatefulWidget { - const DailyFragment({Key key}) : super(key: key); + const DailyFragment({Key? key}) : super(key: key); @override _DailyFragmentState createState() { @@ -48,7 +48,7 @@ class _DailyFragmentState extends State { shrinkWrap: true, physics: const NeverScrollableScrollPhysics(), itemBuilder: (cxt, index) { - final list = snapshot.calendarRequests.requestsDetails; + final list = snapshot.calendarRequests!.requestsDetails!; if (snapshot.isCalendarLoading) return const SizedBox().toRequestShimmer(cxt, snapshot.isCalendarLoading); bool isServiceRequest = list[index].nameOfType == "ServiceRequest"; bool isGasRefill = list[index].nameOfType == "GasRefill"; @@ -70,7 +70,7 @@ class _DailyFragmentState extends State { ); }, separatorBuilder: (cxt, index) => 8.height, - itemCount: snapshot.isCalendarLoading ? 6 : snapshot.calendarRequests.requestsDetails.length, + itemCount: snapshot.isCalendarLoading ? 6 : snapshot.calendarRequests!.requestsDetails!.length, ), ], ).toShadowContainer(context); @@ -78,5 +78,5 @@ class _DailyFragmentState extends State { ); } - BoxDecoration cellDecoration({Color color}) => BoxDecoration(color: color ?? Colors.transparent, shape: BoxShape.circle); + BoxDecoration cellDecoration({Color? color}) => BoxDecoration(color: color ?? Colors.transparent, shape: BoxShape.circle); } diff --git a/lib/new_views/pages/land_page/calender_fragments/monthly_fragment.dart b/lib/new_views/pages/land_page/calender_fragments/monthly_fragment.dart index 512e1d22..e5edda33 100644 --- a/lib/new_views/pages/land_page/calender_fragments/monthly_fragment.dart +++ b/lib/new_views/pages/land_page/calender_fragments/monthly_fragment.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:flutter_month_picker/flutter_month_picker.dart'; +import 'package:flutter_custom_month_picker/flutter_custom_month_picker.dart'; import 'package:intl/intl.dart'; import 'package:provider/provider.dart'; import 'package:table_calendar/table_calendar.dart'; @@ -14,14 +14,14 @@ import 'calendar_header.dart'; import 'calender_days_card.dart'; class MonthlyFragment extends StatefulWidget { - const MonthlyFragment({Key key}) : super(key: key); + const MonthlyFragment({Key? key}) : super(key: key); @override State createState() => _MonthlyFragmentState(); } class _MonthlyFragmentState extends State { - DateTime _initialDate, _firstDate, _lastDate; + late DateTime _initialDate, _firstDate, _lastDate; @override void initState() { @@ -57,17 +57,14 @@ class _MonthlyFragmentState extends State { // lastDate: _lastDate, // initialDatePickerMode: DatePickerMode.year, // ); - final result = await showMonthPicker( - context: context, - initialDate: _initialDate, - firstDate: _firstDate, - lastDate: _lastDate, - ); - if (result != null) { - await snapshot.getCalendarRequests(from: DateTime(result.year, result.month, 1), to: DateTime(result.year, result.month + 1, 0)); - _initialDate = result; + showMonthPicker(context, initialSelectedMonth: _initialDate.month, initialSelectedYear: _initialDate.year, lastEnabledMonth: _lastDate.month, lastYear: _lastDate.year, + onSelected: (month, year) async { + // if (result != null) { + await snapshot.getCalendarRequests(from: DateTime(year, month, 1), to: DateTime(year, month + 1, 0)); + _initialDate = DateTime(year, month); setState(() {}); - } + // } + }); }), dowBuilder: (context, dateTime) { final day = DateFormat("EE", context.isAr ? "ar" : "en").format(dateTime).toUpperCase(); @@ -78,8 +75,8 @@ class _MonthlyFragmentState extends State { return CalendarDaysCard( day: day, fill: snapshot.calendarRequests?.requestsDetails?.firstWhere( - (element) => (element.date != null) && (DateTime.tryParse(element.date)?.difference(dateTime)?.inDays == 0), - orElse: () => null, + (element) => (element.date != null) && (DateTime.tryParse(element.date!)?.difference(dateTime)?.inDays == 0), + orElse: null, ) != null, ).toShimmer(isShow: snapshot.isCalendarLoading); diff --git a/lib/new_views/pages/land_page/calender_fragments/weekly_fragment.dart b/lib/new_views/pages/land_page/calender_fragments/weekly_fragment.dart index 02ab916b..51ebc96e 100644 --- a/lib/new_views/pages/land_page/calender_fragments/weekly_fragment.dart +++ b/lib/new_views/pages/land_page/calender_fragments/weekly_fragment.dart @@ -16,7 +16,7 @@ import '../requests/service_request_item_view.dart'; import 'calender_days_card.dart'; class WeeklyFragment extends StatefulWidget { - const WeeklyFragment({Key key}) : super(key: key); + const WeeklyFragment({Key? key}) : super(key: key); @override _WeeklyFragmentState createState() { @@ -25,7 +25,7 @@ class WeeklyFragment extends StatefulWidget { } class _WeeklyFragmentState extends State { - DateTime _initialDate, _firstDate, _lastDate; + late DateTime _initialDate, _firstDate, _lastDate; @override void initState() { @@ -77,9 +77,9 @@ class _WeeklyFragmentState extends State { final day = DateFormat("d").format(dateTime); return CalendarDaysCard( day: day, - fill: snapshot.calendarRequests.requestsDetails?.firstWhere( - (element) => (element.date != null) && (DateTime.tryParse(element.date).day == (dateTime)?.day), - orElse: () => null, + fill: snapshot.calendarRequests!.requestsDetails?.firstWhere( + (element) => (element.date != null) && (DateTime.tryParse(element.date!)?.day == (dateTime)?.day), + orElse: null, ) != null, ).toShimmer(isShow: snapshot.isCalendarLoading); @@ -88,9 +88,9 @@ class _WeeklyFragmentState extends State { final day = DateFormat("d").format(dateTime); return CalendarDaysCard( day: day, - fill: snapshot.calendarRequests.requestsDetails?.firstWhere( - (element) => (element.date != null) && (DateTime.tryParse(element.date).day == (dateTime)?.day), - orElse: () => null, + fill: snapshot.calendarRequests!.requestsDetails?.firstWhere( + (element) => (element.date != null) && (DateTime.tryParse(element.date!)?.day == (dateTime)?.day), + orElse: null, ) != null, ).toShimmer(isShow: snapshot.isCalendarLoading); @@ -109,7 +109,7 @@ class _WeeklyFragmentState extends State { shrinkWrap: true, physics: const NeverScrollableScrollPhysics(), itemBuilder: (cxt, index) { - final list = snapshot.calendarRequests.requestsDetails; + final list = snapshot.calendarRequests!.requestsDetails!; if (snapshot.isCalendarLoading) return const SizedBox().toRequestShimmer(cxt, snapshot.isCalendarLoading); bool isServiceRequest = list[index].nameOfType == "ServiceRequest"; bool isGasRefill = list[index].nameOfType == "GasRefill"; @@ -131,7 +131,7 @@ class _WeeklyFragmentState extends State { ); }, separatorBuilder: (cxt, index) => const Divider().defaultStyle(context), - itemCount: snapshot.isCalendarLoading ? 6 : snapshot.calendarRequests.requestsDetails.length, + itemCount: snapshot.isCalendarLoading ? 6 : snapshot.calendarRequests!.requestsDetails!.length, ), ], ).toShadowContainer(context); @@ -139,5 +139,5 @@ class _WeeklyFragmentState extends State { ); } - BoxDecoration cellDecoration({Color color}) => BoxDecoration(color: color ?? Colors.transparent, shape: BoxShape.circle); + BoxDecoration cellDecoration({Color? color}) => BoxDecoration(color: color ?? Colors.transparent, shape: BoxShape.circle); } diff --git a/lib/new_views/pages/land_page/contact_us_bottom_sheet.dart b/lib/new_views/pages/land_page/contact_us_bottom_sheet.dart index 0500606c..e3924e62 100644 --- a/lib/new_views/pages/land_page/contact_us_bottom_sheet.dart +++ b/lib/new_views/pages/land_page/contact_us_bottom_sheet.dart @@ -9,7 +9,7 @@ import 'package:url_launcher/url_launcher_string.dart'; import '../../app_style/app_color.dart'; class ContactUsBottomSheet extends StatelessWidget { - const ContactUsBottomSheet({Key key}) : super(key: key); + const ContactUsBottomSheet({Key? key}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/new_views/pages/land_page/dashboard_fragments/progress_fragment.dart b/lib/new_views/pages/land_page/dashboard_fragments/progress_fragment.dart index 409d9714..edf6ec95 100644 --- a/lib/new_views/pages/land_page/dashboard_fragments/progress_fragment.dart +++ b/lib/new_views/pages/land_page/dashboard_fragments/progress_fragment.dart @@ -14,7 +14,7 @@ // import '../../../../models/enums/user_types.dart'; // // class ProgressFragment extends StatelessWidget { -// ProgressFragment({Key key}) : super(key: key); +// ProgressFragment({Key? key}) : super(key: key); // // UserProvider _userProvider; // @@ -163,16 +163,14 @@ import '../../../../controllers/providers/api/user_provider.dart'; import '../../../../models/enums/user_types.dart'; class ProgressFragment extends StatelessWidget { - ProgressFragment({Key key}) : super(key: key); + ProgressFragment({Key? key}) : super(key: key); - UserProvider _userProvider; - - AllRequestsProvider _provider; + late UserProvider _userProvider; @override Widget build(BuildContext context) { _userProvider = Provider.of(context); - bool isCurrentUserNotEngineer = (_userProvider.user.type != UsersTypes.engineer); + bool isCurrentUserNotEngineer = (_userProvider.user!.type != UsersTypes.engineer); return Consumer( builder: (context, snapshot, _) { int total = (snapshot.completedRequests?.total?.count ?? 0) + (snapshot.inProgressRequests?.total?.count ?? 0) + (isCurrentUserNotEngineer ? (snapshot.openRequests?.total?.count ?? 0) : 0); @@ -186,13 +184,9 @@ class ProgressFragment extends StatelessWidget { if (isCurrentUserNotEngineer) { chartData.insert(1, ChartData('Open', snapshot.openRequests?.total?.count?.toDouble() ?? 0.0, AppColor.blueStatus(context))); } - print('conditon value is ${ - snapshot.isInProgressLoading - }');print('conditon value is ${ - snapshot.isCompleteLoading - }');print('conditon value is ${ - snapshot.isOpenLoading - }'); + print('conditon value is ${snapshot.isInProgressLoading}'); + print('conditon value is ${snapshot.isCompleteLoading}'); + print('conditon value is ${snapshot.isOpenLoading}'); return Column( children: [ diff --git a/lib/new_views/pages/land_page/dashboard_fragments/recent_activites_fragment.dart b/lib/new_views/pages/land_page/dashboard_fragments/recent_activites_fragment.dart index addb46a7..0c189701 100644 --- a/lib/new_views/pages/land_page/dashboard_fragments/recent_activites_fragment.dart +++ b/lib/new_views/pages/land_page/dashboard_fragments/recent_activites_fragment.dart @@ -12,7 +12,7 @@ // import 'package:test_sa/views/widgets/notifications/notification_item.dart'; // // class RecentActivitiesFragment extends StatelessWidget { -// RecentActivitiesFragment({Key key}) : super(key: key); +// RecentActivitiesFragment({Key? key}) : super(key: key); // // //NotificationsProvider _notificationsProvider; // @@ -85,7 +85,7 @@ import 'package:test_sa/new_views/app_style/app_color.dart'; import 'package:test_sa/views/widgets/notifications/notification_item.dart'; class RecentActivitiesFragment extends StatelessWidget { - RecentActivitiesFragment({Key key}) : super(key: key); + RecentActivitiesFragment({Key? key}) : super(key: key); //NotificationsProvider _notificationsProvider; @@ -94,11 +94,11 @@ class RecentActivitiesFragment extends StatelessWidget { //_notificationsProvider ??= Provider.of(context, listen: false); return Consumer(builder: (context, _notificationsProvider, _) { UserProvider _userProvider = Provider.of(context); - bool isCurrentUserNotEngineer = (_userProvider.user.type != UsersTypes.engineer); + bool isCurrentUserNotEngineer = (_userProvider.user!.type != UsersTypes.engineer); return RefreshIndicator( onRefresh: () { Provider.of(context, listen: false).getRequests(); - _notificationsProvider.getSystemNotifications(user: Provider.of(context, listen: false).user,resetProvider: true); + _notificationsProvider.getSystemNotifications(user: Provider.of(context, listen: false).user!,resetProvider: true); return Future.delayed(const Duration(microseconds: 250)); }, child: SingleChildScrollView( diff --git a/lib/new_views/pages/land_page/dashboard_fragments/request_category_fragment.dart b/lib/new_views/pages/land_page/dashboard_fragments/request_category_fragment.dart index fad13590..483f98fe 100644 --- a/lib/new_views/pages/land_page/dashboard_fragments/request_category_fragment.dart +++ b/lib/new_views/pages/land_page/dashboard_fragments/request_category_fragment.dart @@ -12,7 +12,7 @@ // import 'package:test_sa/views/widgets/notifications/notification_item.dart'; // // class RequestCategoryFragment extends StatelessWidget { -// RequestCategoryFragment({Key key}) : super(key: key); +// RequestCategoryFragment({Key? key}) : super(key: key); // // //NotificationsProvider _notificationsProvider; // @@ -73,23 +73,19 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:test_sa/controllers/providers/api/all_requests_provider.dart'; -import 'package:test_sa/controllers/providers/api/notifications_provider.dart'; import 'package:test_sa/controllers/providers/api/user_provider.dart'; import 'package:test_sa/extensions/context_extension.dart'; import 'package:test_sa/extensions/int_extensions.dart'; import 'package:test_sa/extensions/text_extensions.dart'; import 'package:test_sa/extensions/widget_extensions.dart'; -import 'package:test_sa/models/all_requests_and_count_model.dart'; import 'package:test_sa/models/enums/user_types.dart'; -import 'package:test_sa/models/user.dart'; import 'package:test_sa/new_views/common_widgets/tab_button.dart'; import 'package:test_sa/new_views/pages/land_page/dashboard_fragments/request_category_list.dart'; import 'package:test_sa/utilities/request_utils.dart'; -import 'package:test_sa/views/widgets/loaders/loading_manager.dart'; class RequestCategoryFragment extends StatelessWidget { const RequestCategoryFragment({ - Key key, + Key? key, }) : super(key: key); @override @@ -101,7 +97,7 @@ class RequestCategoryFragment extends StatelessWidget { getTabs( requestsProvider: allRequestProvider, context: context, - userType: Provider.of(context, listen: false).user.type, + userType: Provider.of(context, listen: false).user!.type!, ), 16.height, allRequestProvider.isFilterRequestLoading || allRequestProvider.filterRequest == null @@ -113,12 +109,12 @@ class RequestCategoryFragment extends StatelessWidget { child: const SizedBox().toRequestShimmer(context, allRequestProvider.isFilterRequestLoading), ); })) - : RequestCategoryList(allRequestProvider.filterRequest.requestsDetails ?? [], allRequestProvider.isFilterRequestLoading, allRequestProvider.filterRequest.total.count), + : RequestCategoryList(allRequestProvider.filterRequest?.requestsDetails ?? [], allRequestProvider.isFilterRequestLoading, allRequestProvider?.filterRequest?.total?.count ?? 0), ]); }); } - Widget getTabs({@required BuildContext context, @required AllRequestsProvider requestsProvider, @required UsersTypes userType}) { + Widget getTabs({required BuildContext context, required AllRequestsProvider requestsProvider, required UsersTypes userType}) { List tabs = []; switch (userType) { case UsersTypes.engineer: @@ -150,14 +146,14 @@ class RequestCategoryFragment extends StatelessWidget { } } - Widget tabWidget({@required int selectedTab, @required String label, @required int status, double width, @required AllRequestsProvider requestsProvider}) { + Widget tabWidget({required int selectedTab, required String label, required int status, required AllRequestsProvider requestsProvider}) { return Padding( padding: const EdgeInsets.only(right: 12), child: TabButton( label: label, loading: requestsProvider.isFilterRequestLoading, isSelected: requestsProvider.currentListIndex == selectedTab, - count: requestsProvider.filterRequest != null ? requestsProvider.filterRequest.total.count : 0, + count: requestsProvider.filterRequest != null ? requestsProvider.filterRequest!.total!.count! : 0, onPressed: () async { requestsProvider.currentListIndex = selectedTab; requestsProvider.filterRequest = null; @@ -174,7 +170,7 @@ class RequestCategoryFragment extends StatelessWidget { //tabs code... // -// List _getTabButtonData({@required bool isEngineer, @required AllRequestsProvider allRequestsProvider, @required int totalCount}) { +// List _getTabButtonData({required bool isEngineer, required AllRequestsProvider allRequestsProvider, required int totalCount}) { // List tabList = []; // List> tabs = []; // print('dashboard filter list data is ${allRequestsProvider.dashBoardFilterList}'); @@ -213,7 +209,7 @@ class RequestCategoryFragment extends StatelessWidget { // return tabList; // } // -// List _buildTabButtons({@required bool isEngineer, @required AllRequestsProvider allRequestsProvider}) { +// List _buildTabButtons({required bool isEngineer, required AllRequestsProvider allRequestsProvider}) { // int totalCount = 0; // print('build tab button called'); // if (allRequestsProvider.dashBoardFilterList != null) { diff --git a/lib/new_views/pages/land_page/dashboard_fragments/request_category_list.dart b/lib/new_views/pages/land_page/dashboard_fragments/request_category_list.dart index d461bd22..5fe446e1 100644 --- a/lib/new_views/pages/land_page/dashboard_fragments/request_category_list.dart +++ b/lib/new_views/pages/land_page/dashboard_fragments/request_category_list.dart @@ -13,7 +13,7 @@ class RequestCategoryList extends StatelessWidget { final List list; final int totalCount; final bool isLoading; - const RequestCategoryList(this.list, this.isLoading, this.totalCount, {Key key}) : super(key: key); + const RequestCategoryList(this.list, this.isLoading, this.totalCount, {Key? key}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/new_views/pages/land_page/dashboard_fragments/requests_fragment.dart b/lib/new_views/pages/land_page/dashboard_fragments/requests_fragment.dart index 0885c3fe..0aebb021 100644 --- a/lib/new_views/pages/land_page/dashboard_fragments/requests_fragment.dart +++ b/lib/new_views/pages/land_page/dashboard_fragments/requests_fragment.dart @@ -13,7 +13,7 @@ import 'package:test_sa/new_views/common_widgets/custom_badge.dart'; import 'package:test_sa/new_views/pages/land_page/requests_list_page.dart'; class RequestsFragment extends StatelessWidget { - const RequestsFragment({Key key}) : super(key: key); + const RequestsFragment({Key? key}) : super(key: key); @override Widget build(BuildContext context) { @@ -25,7 +25,7 @@ class RequestsFragment extends StatelessWidget { gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 4, childAspectRatio: 75 / 84, crossAxisSpacing: 2, mainAxisSpacing: 13), children: [ listItem( - snapshot.highPriorityRequests?.total?.count, + snapshot.highPriorityRequests?.total?.count ?? 0, "high_priority", context.translation.highPriority, context, @@ -33,10 +33,10 @@ class RequestsFragment extends StatelessWidget { 0, context.isDark ? AppColor.redStatus(context) : AppColor.red50, ), - listItem(snapshot.overdueRequests?.total?.count, "overdue", context.translation.overdue, context, snapshot.isOverdueLoading, 1, AppColor.yellowIcon(context)), - listItem(snapshot.openRequests?.total?.count, "new_request", ApiManager.instance.user.type == UsersTypes.engineer ? context.translation.inProgress : context.translation.newR, context, + listItem(snapshot.overdueRequests?.total?.count ?? 0, "overdue", context.translation.overdue, context, snapshot.isOverdueLoading, 1, AppColor.yellowIcon(context)), + listItem(snapshot.openRequests?.total?.count ?? 0, "new_request", ApiManager.instance.user!.type == UsersTypes.engineer ? context.translation.inProgress : context.translation.newR, context, snapshot.isOpenLoading, 2, AppColor.primary40), - listItem(snapshot.completedRequests?.total?.count, "complete_request", context.translation.completed, context, snapshot.isCompleteLoading, 3, AppColor.greenStatus(context)), + listItem(snapshot.completedRequests?.total?.count ?? 0, "complete_request", context.translation.completed, context, snapshot.isCompleteLoading, 3, AppColor.greenStatus(context)), ], ), ); @@ -58,7 +58,7 @@ class RequestsFragment extends StatelessWidget { Navigator.push( context, MaterialPageRoute( - builder: (context) => RequestsListPage(index,title), + builder: (context) => RequestsListPage(index, title), ), ); }, @@ -107,7 +107,7 @@ class RequestsFragment extends StatelessWidget { // import 'package:test_sa/new_views/pages/land_page/requests_list_page.dart'; // // class RequestsFragment extends StatelessWidget { -// const RequestsFragment({Key key}) : super(key: key); +// const RequestsFragment({Key? key}) : super(key: key); // // @override // Widget build(BuildContext context) { @@ -246,7 +246,7 @@ class RequestsFragment extends StatelessWidget { // import 'package:test_sa/new_views/pages/land_page/requests_list_page.dart'; // // class RequestsFragment extends StatelessWidget { -// const RequestsFragment({Key key}) : super(key: key); +// const RequestsFragment({Key? key}) : super(key: key); // // @override // Widget build(BuildContext context) { diff --git a/lib/new_views/pages/land_page/dashboard_page.dart b/lib/new_views/pages/land_page/dashboard_page.dart index eb1b9127..7d160082 100644 --- a/lib/new_views/pages/land_page/dashboard_page.dart +++ b/lib/new_views/pages/land_page/dashboard_page.dart @@ -22,7 +22,7 @@ import 'package:test_sa/views/pages/user/notifications/notifications_page.dart'; class DashboardPage extends StatefulWidget { final VoidCallback onDrawerPress; - const DashboardPage({Key key, this.onDrawerPress}) : super(key: key); + const DashboardPage({Key? key,required this.onDrawerPress}) : super(key: key); @override State createState() => _DashboardPageState(); @@ -40,7 +40,7 @@ class _DashboardPageState extends State { void getAllRequests() { WidgetsBinding.instance.addPostFrameCallback((_) { Provider.of(context, listen: false).getRequests(); - Provider.of(context, listen: false).getSystemNotifications(user: Provider.of(context, listen: false).user, resetProvider: true); + Provider.of(context, listen: false).getSystemNotifications(user: Provider.of(context, listen: false).user!, resetProvider: true); }); } @@ -56,12 +56,12 @@ class _DashboardPageState extends State { if (isFCM) { FirebaseNotificationManger.initialized(context); NotificationManger.initialisation((notificationDetails) { - FirebaseNotificationManger.handleMessage(context, json.decode(notificationDetails.payload)); + FirebaseNotificationManger.handleMessage(context, json.decode(notificationDetails.payload!)); }, (id, title, body, payload) async {}); isFCM = false; } - final user = Provider.of(context, listen: false).user; + final User user = Provider.of(context, listen: false).user!; final setting = Provider.of(context, listen: false); return Scaffold( appBar: AppBar( @@ -80,9 +80,9 @@ class _DashboardPageState extends State { padding: const EdgeInsets.all(1), // Border radius child: ClipOval( child: snapshot.profileImage != null - ? Image.file(snapshot.profileImage) - : (snapshot.user.profilePhotoName?.isNotEmpty ?? false) - ? Image.network(snapshot.user.profilePhotoName) + ? Image.file(snapshot.profileImage!) + : (snapshot.user?.profilePhotoName?.isNotEmpty ?? false) + ? Image.network(snapshot.user!.profilePhotoName!) : const Icon(Icons.person, size: 24, color: Colors.white), ), ), @@ -120,7 +120,7 @@ class _DashboardPageState extends State { getAllRequests(); } }, - items: user.assetGroups.map>((value) { + items: user.assetGroups!.map>((value) { return DropdownMenuItem( value: value, child: Text( diff --git a/lib/new_views/pages/land_page/home_app_bar.dart b/lib/new_views/pages/land_page/home_app_bar.dart index b6cc126e..60bbb583 100644 --- a/lib/new_views/pages/land_page/home_app_bar.dart +++ b/lib/new_views/pages/land_page/home_app_bar.dart @@ -8,7 +8,7 @@ // class HomeAppBar extends StatelessWidget implements PreferredSizeWidget { // final GlobalKey scaffoldKey; // -// const HomeAppBar({Key key, this.scaffoldKey}) : super(key: key); +// const HomeAppBar({Key? key, this.scaffoldKey}) : super(key: key); // // @override // Size get preferredSize => Size.fromHeight(60.toScreenHeight); diff --git a/lib/new_views/pages/land_page/land_page.dart b/lib/new_views/pages/land_page/land_page.dart index 0dbd7ed2..35611896 100644 --- a/lib/new_views/pages/land_page/land_page.dart +++ b/lib/new_views/pages/land_page/land_page.dart @@ -28,7 +28,7 @@ import 'dashboard_page.dart'; class LandPage extends StatefulWidget { static const String routeName = "/land-page"; - const LandPage({Key key}) : super(key: key); + const LandPage({Key? key}) : super(key: key); @override State createState() => _LandPageState(); @@ -38,8 +38,8 @@ class _LandPageState extends State { final GlobalKey _scaffoldKey = GlobalKey(); int currentPageIndex = 0; bool showAppbar = true; - List _pages; - UserProvider _userProvider; + late List _pages; + UserProvider? _userProvider; @override void initState() { @@ -103,12 +103,12 @@ class _LandPageState extends State { _userProvider = Provider.of(context, listen: false); _pages = [ DashboardView(onDrawerPress: (() { - _scaffoldKey.currentState.isDrawerOpen ? _scaffoldKey.currentState.closeDrawer() : _scaffoldKey.currentState.openDrawer(); + _scaffoldKey.currentState!.isDrawerOpen ? _scaffoldKey.currentState!.closeDrawer() : _scaffoldKey.currentState!.openDrawer(); })), // const old_page.LandPage(), const MyRequestsPage(), const MyAssetsPage(fromBottomBar: true), - if (_userProvider.user.type == UsersTypes.engineer) const CalendarPage(), + if (_userProvider!.user!.type == UsersTypes.engineer) const CalendarPage(), ]; checkLocalAuth(); } @@ -134,7 +134,7 @@ class _LandPageState extends State { bottomNavigationBar: AppBottomNavigationBar( selectedIndex: currentPageIndex, onPressed: (index) { - bool isEngineer = _userProvider.user.type == UsersTypes.engineer; + bool isEngineer = _userProvider!.user!.type == UsersTypes.engineer; if (index == (isEngineer ? 4 : 3)) { showModalBottomSheet( diff --git a/lib/new_views/pages/land_page/my_request/all_requests_filter_page.dart b/lib/new_views/pages/land_page/my_request/all_requests_filter_page.dart index 34175742..15ac42f5 100644 --- a/lib/new_views/pages/land_page/my_request/all_requests_filter_page.dart +++ b/lib/new_views/pages/land_page/my_request/all_requests_filter_page.dart @@ -16,27 +16,27 @@ import '../../../common_widgets/app_lazy_loading.dart'; class AllRequestsFilterPage extends StatefulWidget { static const String id = "all_requests_filter_page"; - final SearchAllRequestsModel data; + final SearchAllRequestsModel? data; - const AllRequestsFilterPage({Key key, this.data}) : super(key: key); + const AllRequestsFilterPage({Key? key, this.data}) : super(key: key); @override State createState() => _AllRequestsFilterPageState(); } class _AllRequestsFilterPageState extends State { - SearchAllRequestsModel search; + SearchAllRequestsModel? search; @override void initState() { search = widget.data; if (search != null) { - search.requestNumber.controller.text = search.requestNumber.value; - search.assetName.controller.text = search.assetName.value; - search.assetNo.controller.text = search.assetNo.value; - search.manufacture.controller.text = search.manufacture.value; - search.sn.controller.text = search.sn.value; - search.model.controller.text = search.model.value; + search?.requestNumber?.controller?.text = search?.requestNumber?.value ?? ""; + search!.assetName?.controller?.text = search?.assetName?.value ?? ""; + search!.assetNo?.controller?.text = search?.assetNo!.value ?? ""; + search!.manufacture?.controller?.text = search?.manufacture!.value ?? ""; + search!.sn?.controller?.text = search?.sn?.value ?? ""; + search!.model?.controller?.text = search?.model?.value ?? ""; } super.initState(); } @@ -52,7 +52,7 @@ class _AllRequestsFilterPageState extends State { sn: SearchBySNModel(context, controller: TextEditingController()), model: SearchByRequestModel(context, controller: TextEditingController()), ); - search.searchBySelectedValue = search.requestNumber; + search!.searchBySelectedValue = search?.requestNumber; } final types = { context.translation.serviceRequest: 1, @@ -81,11 +81,11 @@ class _AllRequestsFilterPageState extends State { ).paddingAll(8).onPress(() { Provider.of(context, listen: false).searchedModel = null; setState(() { - search.statuses?.clear(); - search.typeTransaction?.clear(); - search.startDate = null; - search.endDate = null; - search.isArchived = null; + search?.statuses?.clear(); + search?.typeTransaction?.clear(); + search?.startDate = null; + search?.endDate = null; + search?.isArchived = false; }); }), ], @@ -101,15 +101,15 @@ class _AllRequestsFilterPageState extends State { context.translation.requestStatus.heading5(context), 8.height, RequestsTypeFilter( - initialValues: search.statuses, + initialValues: search?.statuses ?? [], items: statuses, onSelect: (value) { if (value.isNotEmpty && value.last == 0) { - search.statuses = [0]; + search!.statuses = [0]; } else if (value.contains(0)) { - search.statuses.remove(0); + search?.statuses?.remove(0); } else { - search.statuses = value; + search?.statuses = value; } setState(() {}); }, @@ -118,10 +118,10 @@ class _AllRequestsFilterPageState extends State { context.translation.typeOfRequest.heading5(context), 8.height, RequestsTypeFilter( - initialValues: search.typeTransaction, + initialValues: search?.typeTransaction ?? [], items: types, onSelect: (value) { - search.typeTransaction = value; + search?.typeTransaction = value; setState(() {}); }, ), @@ -133,10 +133,10 @@ class _AllRequestsFilterPageState extends State { ADatePicker( label: context.translation.from, from: DateTime(2000), - date: search.startDate, + date: search!.startDate!, onDatePicker: (date) { setState(() { - search.startDate = date; + search!.startDate = date; }); }, ).expanded, @@ -144,10 +144,10 @@ class _AllRequestsFilterPageState extends State { ADatePicker( label: context.translation.to, from: DateTime(2000), - date: search.endDate, + date: search!.endDate!, onDatePicker: (date) { setState(() { - search.endDate = date; + search!.endDate = date; }); }, ).expanded, @@ -162,15 +162,15 @@ class _AllRequestsFilterPageState extends State { value: search?.isArchived ?? false, activeColor: AppColor.blueStatus(context), onChanged: (value) { - if (search.isArchived != value) { - search.isArchived = value; + if (search?.isArchived != value) { + search?.isArchived = value!; } if (mounted) setState(() {}); }), "View Archived Requests".bodyText(context).expanded, ], ).onPress(() { - search.isArchived = !search.isArchived; + search?.isArchived = !search!.isArchived; setState(() {}); }), ], @@ -184,7 +184,7 @@ class _AllRequestsFilterPageState extends State { void _search() async { final requestsProvider = Provider.of(context, listen: false); - if (search.startDate != null) search.endDate ??= DateTime.now(); + if (search?.startDate != null) search?.endDate ??= DateTime.now(); showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading()); requestsProvider.reset(); requestsProvider.searchedModel = search; @@ -194,6 +194,6 @@ class _AllRequestsFilterPageState extends State { } bool _showResetButton() { - return (search.statuses?.isNotEmpty ?? false) || (search.typeTransaction?.isNotEmpty ?? false) || (search.startDate != null) || (search.endDate != null) || (search.isArchived ?? false); + return (search?.statuses?.isNotEmpty ?? false) || (search?.typeTransaction?.isNotEmpty ?? false) || (search?.startDate != null) || (search?.endDate != null) || (search?.isArchived ?? false); } } diff --git a/lib/new_views/pages/land_page/my_request/all_requests_search_page.dart b/lib/new_views/pages/land_page/my_request/all_requests_search_page.dart index 1a6d916e..4011f156 100644 --- a/lib/new_views/pages/land_page/my_request/all_requests_search_page.dart +++ b/lib/new_views/pages/land_page/my_request/all_requests_search_page.dart @@ -17,28 +17,28 @@ import '../widgets/request_search_buttons.dart'; class AllRequestsSearchPage extends StatefulWidget { static const String id = "all_requests_search_page"; - final SearchAllRequestsModel data; + final SearchAllRequestsModel? data; - const AllRequestsSearchPage({Key key, this.data}) : super(key: key); + const AllRequestsSearchPage({Key? key, this.data}) : super(key: key); @override State createState() => _AllRequestsSearchPageState(); } class _AllRequestsSearchPageState extends State { - SearchAllRequestsModel search; + SearchAllRequestsModel? search; final GlobalKey _formKey = GlobalKey(); @override void initState() { search = widget.data; if (search != null) { - search.requestNumber.controller.text = search.requestNumber.value; - search.assetName.controller.text = search.assetName.value; - search.assetNo.controller.text = search.assetNo.value; - search.manufacture.controller.text = search.manufacture.value; - search.sn.controller.text = search.sn.value; - search.model.controller.text = search.model.value; + search!.requestNumber?.controller?.text = search?.requestNumber?.value ?? ""; + search!.assetName?.controller?.text = search?.assetName?.value ?? ""; + search!.assetNo?.controller?.text = search?.assetNo?.value ?? ""; + search!.manufacture?.controller?.text = search?.manufacture?.value ?? ""; + search!.sn?.controller?.text = search?.sn?.value ?? ""; + search!.model?.controller?.text = search?.model?.value ?? ""; } super.initState(); } @@ -54,7 +54,7 @@ class _AllRequestsSearchPageState extends State { sn: SearchBySNModel(context, controller: TextEditingController()), model: SearchByRequestModel(context, controller: TextEditingController()), ); - search.searchBySelectedValue = search.requestNumber; + search!.searchBySelectedValue = search?.requestNumber; } return Scaffold( @@ -78,7 +78,7 @@ class _AllRequestsSearchPageState extends State { style: AppTextStyles.bodyText2.copyWith(color: const Color(0xFF4A8DB7)), ).paddingAll(8).onPress(() { setState(() { - search.resetSearchValues(); + search!.resetSearchValues(); }); }), ], @@ -96,28 +96,28 @@ class _AllRequestsSearchPageState extends State { context.translation.searchBy.heading5(context), 8.height, RequestsSearchButtons( - items: [search.requestNumber, search.assetName, search.assetNo, search.manufacture, search.sn, search.model], - initialValue: search.searchBySelectedValue, + items: [search!.requestNumber!, search!.assetName!, search!.assetNo!, search!.manufacture!, search!.sn!, search!.model!], + initialValue: search!.searchBySelectedValue!, onSelect: (value) { - if (search.searchBySelectedValue != value) { - search.searchBySelectedValue = value; - search.resetSearchValues(); + if (search!.searchBySelectedValue != value) { + search!.searchBySelectedValue = value; + search!.resetSearchValues(); setState(() {}); } }, ), 16.height, AppTextFormField( - controller: search.searchBySelectedValue.controller, - labelText: search.searchBySelectedValue.label, - textInputType: search.searchBySelectedValue.inputType, + controller: search!.searchBySelectedValue?.controller, + labelText: search!.searchBySelectedValue?.label, + textInputType: search!.searchBySelectedValue?.inputType, onChange: (text) { - search.searchBySelectedValue.controller.text = text; - search.searchBySelectedValue.controller.selection = TextSelection.fromPosition(TextPosition(offset: search.searchBySelectedValue.controller.text.length)); + search!.searchBySelectedValue?.controller?.text = text; + search!.searchBySelectedValue?.controller?.selection = TextSelection.fromPosition(TextPosition(offset: search!.searchBySelectedValue!.controller!.text.length)); setState(() {}); }, onSaved: (value) { - search.searchBySelectedValue.value = value; + search!.searchBySelectedValue!.value = value; }, ), ], @@ -131,8 +131,8 @@ class _AllRequestsSearchPageState extends State { } void _search() async { - if (_formKey.currentState.validate()) { - _formKey.currentState.save(); + if (_formKey.currentState!.validate()) { + _formKey.currentState!.save(); final requestsProvider = Provider.of(context, listen: false); showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading()); requestsProvider.reset(); @@ -143,11 +143,11 @@ class _AllRequestsSearchPageState extends State { } bool _showResetButton() { - return (search.requestNumber?.controller?.text?.isNotEmpty ?? false) || - (search.assetName?.controller?.text?.isNotEmpty ?? false) || - (search.assetNo?.controller?.text?.isNotEmpty ?? false) || - (search.manufacture?.controller?.text?.isNotEmpty ?? false) || - (search.sn?.controller?.text?.isNotEmpty ?? false) || - (search.model?.controller?.text?.isNotEmpty ?? false); + return (search?.requestNumber?.controller?.text?.isNotEmpty ?? false) || + (search?.assetName?.controller?.text?.isNotEmpty ?? false) || + (search?.assetNo?.controller?.text?.isNotEmpty ?? false) || + (search?.manufacture?.controller?.text?.isNotEmpty ?? false) || + (search?.sn?.controller?.text?.isNotEmpty ?? false) || + (search?.model?.controller?.text?.isNotEmpty ?? false); } } diff --git a/lib/new_views/pages/land_page/my_request/my_requests_page.dart b/lib/new_views/pages/land_page/my_request/my_requests_page.dart index 7ee0e6f7..a6ab4a78 100644 --- a/lib/new_views/pages/land_page/my_request/my_requests_page.dart +++ b/lib/new_views/pages/land_page/my_request/my_requests_page.dart @@ -15,17 +15,17 @@ import 'package:test_sa/new_views/pages/land_page/widgets/request_item_view_list import 'package:test_sa/views/widgets/loaders/lazy_loading.dart'; class MyRequestsPage extends StatefulWidget { - const MyRequestsPage({Key key}) : super(key: key); + const MyRequestsPage({Key? key}) : super(key: key); @override State createState() => _MyRequestsPageState(); } class _MyRequestsPageState extends State { - AllRequestsProvider _provider; - SearchAllRequestsModel _search; + AllRequestsProvider? _provider; + SearchAllRequestsModel? _search; - List requestsList; + late List requestsList; int selectedRequest = 0; @override @@ -39,8 +39,8 @@ class _MyRequestsPageState extends State { context.translation.preventiveMaintenance, ]; _provider = Provider.of(context, listen: false); - _provider.reset(); - _provider.getAllRequests(context); + _provider!.reset(); + _provider!.getAllRequests(context); } return Scaffold( @@ -130,19 +130,19 @@ class _MyRequestsPageState extends State { setState(() { selectedRequest = index; }); - _provider.reset(); - _provider.getAllRequests(context, typeTransaction: selectedRequest == 0 ? null : selectedRequest); + _provider!.reset(); + _provider!.getAllRequests(context, typeTransaction: selectedRequest == 0 ? null : selectedRequest); } }), separatorBuilder: (cxt, index) => 8.width, itemCount: requestsList.length), ), LazyLoading( - child: RequestItemViewList(snapshot.allRequestsAndCount?.requestsDetails ?? [], snapshot.isAllLoading), nextPage: snapshot.nextPage, - onLazyLoad: () { + onLazyLoad: () async { snapshot.getAllRequests(context, typeTransaction: selectedRequest == 0 ? null : selectedRequest, search: _search); }, + child: RequestItemViewList(snapshot.allRequestsAndCount?.requestsDetails ?? [], snapshot.isAllLoading), ).expanded, ], ); @@ -151,14 +151,14 @@ class _MyRequestsPageState extends State { bool _filterIsEmpty() { if (_search == null) return true; - if ((_search.requestNumber?.value?.isNotEmpty ?? false) || - (_search.assetNo?.value?.isNotEmpty ?? false) || - (_search.assetName?.value?.isNotEmpty ?? false) || - (_search.manufacture?.value?.isNotEmpty ?? false) || - (_search.sn?.value?.isNotEmpty ?? false) || - (_search.statuses?.isNotEmpty ?? false) || - (_search.startDate != null) || - (_search.endDate != null)) { + if ((_search!.requestNumber?.value?.isNotEmpty ?? false) || + (_search!.assetNo?.value?.isNotEmpty ?? false) || + (_search!.assetName?.value?.isNotEmpty ?? false) || + (_search!.manufacture?.value?.isNotEmpty ?? false) || + (_search!.sn?.value?.isNotEmpty ?? false) || + (_search!.statuses?.isNotEmpty ?? false) || + (_search!.startDate != null) || + (_search!.endDate != null)) { return false; } return true; diff --git a/lib/new_views/pages/land_page/requests/asset_item_view.dart b/lib/new_views/pages/land_page/requests/asset_item_view.dart index 75186033..070d86b2 100644 --- a/lib/new_views/pages/land_page/requests/asset_item_view.dart +++ b/lib/new_views/pages/land_page/requests/asset_item_view.dart @@ -15,7 +15,7 @@ class AssetItemView extends StatelessWidget { final RequestsDetails request; final bool showShadow; - const AssetItemView(this.request, {Key key, this.showShadow = true}) : super(key: key); + const AssetItemView(this.request, {Key? key, this.showShadow = true}) : super(key: key); @override Widget build(BuildContext context) { @@ -29,8 +29,8 @@ class AssetItemView extends StatelessWidget { if (request.priority != null) StatusLabel( label: request.priority ?? "", - textColor: AppColor.getRequestStatusTextColorByName(context, request.priority), - backgroundColor: AppColor.getRequestStatusColorByName(context, request.priority), + textColor: AppColor.getRequestStatusTextColorByName(context, request.priority!), + backgroundColor: AppColor.getRequestStatusColorByName(context, request.priority!), ), // 8.width, // if (request.status != null) @@ -51,7 +51,7 @@ class AssetItemView extends StatelessWidget { context.translation.deviceTransferRequest.heading5(context), "${context.translation.from} : ${request.siteTransferFrom?.cleanupWhitespace?.capitalizeFirstOfEach}".bodyText(context), "${context.translation.to} : ${request.siteTransferTo?.cleanupWhitespace?.capitalizeFirstOfEach}".bodyText(context), - request.status.replaceAll("=", ":").bodyText(context), + request.status!.replaceAll("=", ":").bodyText(context), '${context.translation.requestNo}: ${request.requestNo}'.bodyText(context), ], ), @@ -72,7 +72,7 @@ class AssetItemView extends StatelessWidget { ), ], ).toShadowContainer(context, showShadow: showShadow).onPress(() { - Navigator.of(context).push(MaterialPageRoute(builder: (_) => DeviceTransferDetails(model: AssetTransfer(id: request.id)))); + Navigator.of(context).push(MaterialPageRoute(builder: (_) => DeviceTransferDetails(model: AssetTransfer(id: request.id!)))); }); } } diff --git a/lib/new_views/pages/land_page/requests/gas_refill_item_view.dart b/lib/new_views/pages/land_page/requests/gas_refill_item_view.dart index 0eff676b..8a4fb3db 100644 --- a/lib/new_views/pages/land_page/requests/gas_refill_item_view.dart +++ b/lib/new_views/pages/land_page/requests/gas_refill_item_view.dart @@ -15,7 +15,7 @@ class GasRefillItemView extends StatelessWidget { final RequestsDetails request; final bool showShadow; - const GasRefillItemView(this.request, {Key key, this.showShadow = true}) : super(key: key); + const GasRefillItemView(this.request, {Key? key, this.showShadow = true}) : super(key: key); @override Widget build(BuildContext context) { @@ -26,15 +26,15 @@ class GasRefillItemView extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ StatusLabel( - label: request.priority, - textColor: AppColor.getRequestStatusTextColorByName(context, request.priority), - backgroundColor: AppColor.getRequestStatusColorByName(context, request.priority), + label: request.priority!, + textColor: AppColor.getRequestStatusTextColorByName(context, request.priority!), + backgroundColor: AppColor.getRequestStatusColorByName(context, request.priority!), ), 8.width, StatusLabel( - label: request.status, - textColor: AppColor.getRequestStatusTextColorByName(context, request.status), - backgroundColor: AppColor.getRequestStatusColorByName(context, request.status), + label: request.status!, + textColor: AppColor.getRequestStatusTextColorByName(context, request.status!), + backgroundColor: AppColor.getRequestStatusColorByName(context, request.status!), ), 1.width.expanded, Text(request.date?.toServiceRequestCardFormat ?? "", textAlign: TextAlign.end, style: AppTextStyles.tinyFont.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral50)), @@ -68,8 +68,8 @@ class GasRefillItemView extends StatelessWidget { Navigator.of(context).push( MaterialPageRoute( builder: (_) => GasRefillDetailsPage( - priority: request.priority, - date: request.date, + priority: request.priority!, + date: request.date!, model: GasRefillModel(id: request.id), ), ), diff --git a/lib/new_views/pages/land_page/requests/ppm_item_view.dart b/lib/new_views/pages/land_page/requests/ppm_item_view.dart index d800b148..21002783 100644 --- a/lib/new_views/pages/land_page/requests/ppm_item_view.dart +++ b/lib/new_views/pages/land_page/requests/ppm_item_view.dart @@ -14,7 +14,7 @@ class PpmItemView extends StatelessWidget { final RequestsDetails request; final bool showShadow; - const PpmItemView(this.request, {Key key, this.showShadow = true}) : super(key: key); + const PpmItemView(this.request, {Key? key, this.showShadow = true}) : super(key: key); @override Widget build(BuildContext context) { @@ -25,15 +25,15 @@ class PpmItemView extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ StatusLabel( - label: request.priority, - textColor: AppColor.getRequestStatusTextColorByName(context, request.priority), - backgroundColor: AppColor.getRequestStatusColorByName(context, request.priority), + label: request.priority!, + textColor: AppColor.getRequestStatusTextColorByName(context, request.priority!), + backgroundColor: AppColor.getRequestStatusColorByName(context, request.priority!), ), 8.width, StatusLabel( - label: request.status, - textColor: AppColor.getRequestStatusTextColorByName(context, request.status), - backgroundColor: AppColor.getRequestStatusColorByName(context, request.status), + label: request.status!, + textColor: AppColor.getRequestStatusTextColorByName(context, request.status!), + backgroundColor: AppColor.getRequestStatusColorByName(context, request.status!), ), 1.width.expanded, Text( diff --git a/lib/new_views/pages/land_page/requests/request_paginated_listview.dart b/lib/new_views/pages/land_page/requests/request_paginated_listview.dart index 6856bb94..239e8cc7 100644 --- a/lib/new_views/pages/land_page/requests/request_paginated_listview.dart +++ b/lib/new_views/pages/land_page/requests/request_paginated_listview.dart @@ -14,7 +14,7 @@ class RequestPaginatedList extends StatelessWidget { final int totalCount; final bool isLoading; ScrollController scrollController; - RequestPaginatedList(this.list, this.isLoading, this.totalCount,this.scrollController, {Key key}) : super(key: key); + RequestPaginatedList(this.list, this.isLoading, this.totalCount,this.scrollController, {Key? key}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/new_views/pages/land_page/requests/service_request_item_view.dart b/lib/new_views/pages/land_page/requests/service_request_item_view.dart index d48d0c66..bac20d28 100644 --- a/lib/new_views/pages/land_page/requests/service_request_item_view.dart +++ b/lib/new_views/pages/land_page/requests/service_request_item_view.dart @@ -6,8 +6,6 @@ import 'package:test_sa/extensions/string_extensions.dart'; import 'package:test_sa/extensions/text_extensions.dart'; import 'package:test_sa/extensions/widget_extensions.dart'; import 'package:test_sa/models/all_requests_and_count_model.dart'; -import 'package:test_sa/models/service_request/service_request.dart'; -import 'package:test_sa/service_request_latest/views/components/request_detail_view.dart'; import 'package:test_sa/service_request_latest/views/request_detail_main_view.dart'; import '../../../../views/widgets/requests/request_status.dart'; @@ -17,11 +15,10 @@ class ServiceRequestItemView extends StatelessWidget { final RequestsDetails request; final bool showShadow; - const ServiceRequestItemView(this.request, {Key key, this.showShadow = true}) : super(key: key); + const ServiceRequestItemView(this.request, {Key? key, this.showShadow = true}) : super(key: key); @override Widget build(BuildContext context) { - return Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, @@ -30,18 +27,18 @@ class ServiceRequestItemView extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ StatusLabel( - label: request.priority, - textColor: AppColor.getRequestStatusTextColorByName(context, request.priority), - backgroundColor: AppColor.getRequestStatusColorByName(context, request.priority), + label: request.priority!, + textColor: AppColor.getRequestStatusTextColorByName(context, request.priority!), + backgroundColor: AppColor.getRequestStatusColorByName(context, request.priority!), ), 8.width, StatusLabel( - label: request.status, - textColor: AppColor.getRequestStatusTextColorByName(context, request.status), - backgroundColor: AppColor.getRequestStatusColorByName(context, request.status), + label: request.status!, + textColor: AppColor.getRequestStatusTextColorByName(context, request.status!), + backgroundColor: AppColor.getRequestStatusColorByName(context, request.status!), ), 1.width.expanded, - Text(request.date.toServiceRequestCardFormat, textAlign: TextAlign.end, style: AppTextStyles.tinyFont.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral50)), + Text(request.date!.toServiceRequestCardFormat, textAlign: TextAlign.end, style: AppTextStyles.tinyFont.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral50)), ], ), 8.height, @@ -73,8 +70,8 @@ class ServiceRequestItemView extends StatelessWidget { Navigator.of(context).push(MaterialPageRoute( builder: (_) => RequestDetailMain( - requestId:request.id, - ))); + requestId: request.id!, + ))); // Navigator.of(context).push(MaterialPageRoute( // builder: (_) => const HistoryLogView())); }); diff --git a/lib/new_views/pages/land_page/requests_list_page.dart b/lib/new_views/pages/land_page/requests_list_page.dart index 105b246a..c416c1c9 100644 --- a/lib/new_views/pages/land_page/requests_list_page.dart +++ b/lib/new_views/pages/land_page/requests_list_page.dart @@ -1,6 +1,5 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; -import 'package:test_sa/controllers/api_routes/api_manager.dart'; import 'package:test_sa/controllers/providers/api/all_requests_provider.dart'; import 'package:test_sa/controllers/providers/api/user_provider.dart'; import 'package:test_sa/extensions/context_extension.dart'; @@ -8,27 +7,23 @@ import 'package:test_sa/extensions/int_extensions.dart'; import 'package:test_sa/extensions/widget_extensions.dart'; import 'package:test_sa/models/all_requests_and_count_model.dart'; import 'package:test_sa/models/enums/user_types.dart'; -import 'package:test_sa/new_views/app_style/app_color.dart'; import 'package:test_sa/new_views/common_widgets/default_app_bar.dart'; -import 'package:test_sa/new_views/pages/land_page/dashboard_fragments/request_category_list.dart'; import 'package:test_sa/new_views/pages/land_page/requests/request_paginated_listview.dart'; -import 'package:test_sa/new_views/pages/land_page/widgets/request_item_view_list.dart'; -import 'package:test_sa/views/widgets/loaders/lazy_loading.dart'; class RequestsListPage extends StatefulWidget { static const String routeName = "/requests-list-page"; final int index; final String title; - const RequestsListPage(this.index, this.title, {Key key}) : super(key: key); + const RequestsListPage(this.index, this.title, {Key? key}) : super(key: key); @override State createState() => _RequestsListPageState(); } class _RequestsListPageState extends State { - AllRequestsProvider _provider; - ScrollController _scrollController; + late AllRequestsProvider _provider; + late ScrollController _scrollController; @override void initState() { @@ -51,12 +46,11 @@ class _RequestsListPageState extends State { void handleScroll() async { _scrollController = ScrollController(); - int pageNo =1; + int pageNo = 1; _scrollController.addListener(() async { if (_scrollController?.position?.pixels == _scrollController?.position?.maxScrollExtent && !_provider.isRequestCategoryLoading) { - pageNo = pageNo + 1; - callRequestApis(showLoader: false,pageNo: pageNo); + callRequestApis(showLoader: false, pageNo: pageNo); } }); } @@ -78,27 +72,27 @@ class _RequestsListPageState extends State { ); } else { snapshot.requestDetailList = snapshot.selectedRequestCategory; - return RequestPaginatedList(snapshot.selectedRequestCategory.requestsDetails ?? [], snapshot.isRequestCategoryLoading, snapshot.selectedRequestCategory.total.count, _scrollController); + return RequestPaginatedList(snapshot.selectedRequestCategory!.requestsDetails ?? [], snapshot.isRequestCategoryLoading, snapshot.selectedRequestCategory!.total!.count!, _scrollController); } - bool isLoading = widget.index == 0 - ? snapshot.isHighPriorityLoading - : widget.index == 1 - ? snapshot.isOverdueLoading - : widget.index == 2 - ? snapshot.isOpenLoading - : widget.index == 3 - ? snapshot.isCompleteLoading - : false; - - List list = widget.index == 0 - ? snapshot.highPriorityRequests?.requestsDetails ?? [] - : widget.index == 1 - ? snapshot.overdueRequests?.requestsDetails ?? [] - : widget.index == 2 - ? snapshot.openRequests?.requestsDetails ?? [] - : widget.index == 3 - ? snapshot.completedRequests?.requestsDetails ?? [] - : []; + // bool isLoading = widget.index == 0 + // ? snapshot.isHighPriorityLoading + // : widget.index == 1 + // ? snapshot.isOverdueLoading + // : widget.index == 2 + // ? snapshot.isOpenLoading + // : widget.index == 3 + // ? snapshot.isCompleteLoading + // : false; + // + // List list = widget.index == 0 + // ? snapshot.highPriorityRequests?.requestsDetails ?? [] + // : widget.index == 1 + // ? snapshot.overdueRequests?.requestsDetails ?? [] + // : widget.index == 2 + // ? snapshot.openRequests?.requestsDetails ?? [] + // : widget.index == 3 + // ? snapshot.completedRequests?.requestsDetails ?? [] + // : []; })); } @@ -107,7 +101,7 @@ class _RequestsListPageState extends State { int pageNo = 1, int pageSize = 10, }) async { - UsersTypes usersTypes = Provider.of(context, listen: false).user.type; + UsersTypes usersTypes = Provider.of(context, listen: false).user!.type!; print('i am here at ${widget.index}'); if (widget.index == 0) { diff --git a/lib/new_views/pages/land_page/widgets/request_item_view_list.dart b/lib/new_views/pages/land_page/widgets/request_item_view_list.dart index 132915ac..b98729ab 100644 --- a/lib/new_views/pages/land_page/widgets/request_item_view_list.dart +++ b/lib/new_views/pages/land_page/widgets/request_item_view_list.dart @@ -16,7 +16,7 @@ class RequestItemViewList extends StatelessWidget { List list; bool isLoading; - RequestItemViewList(this.list, this.isLoading, {Key key}) : super(key: key); + RequestItemViewList(this.list, this.isLoading, {Key? key}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/new_views/pages/land_page/widgets/request_search_buttons.dart b/lib/new_views/pages/land_page/widgets/request_search_buttons.dart index a13a6f32..6ebf120e 100644 --- a/lib/new_views/pages/land_page/widgets/request_search_buttons.dart +++ b/lib/new_views/pages/land_page/widgets/request_search_buttons.dart @@ -12,14 +12,14 @@ class RequestsSearchButtons extends StatefulWidget { final List items; final SearchAllRequestsBaseModel initialValue; - const RequestsSearchButtons({Key key, @required this.items, this.initialValue, this.onSelect}) : super(key: key); + const RequestsSearchButtons({Key? key, required this.items,required this.initialValue,required this.onSelect}) : super(key: key); @override State createState() => _RequestsSearchButtonsState(); } class _RequestsSearchButtonsState extends State { - SearchAllRequestsBaseModel _data; + late SearchAllRequestsBaseModel _data; @override void initState() { @@ -63,7 +63,7 @@ class _RequestsSearchButtonsState extends State { ), shadows: [BoxShadow(color: Colors.black.withOpacity(0.05), blurRadius: 14, offset: const Offset(0, 0), spreadRadius: 0)], ), - child: data.label.tinyFont(context).custom(color: AppColor.filterButtonTextColor(context)), + child: data.label!.tinyFont(context).custom(color: AppColor.filterButtonTextColor(context)), ).onPress( () { setState(() { diff --git a/lib/new_views/pages/land_page/widgets/static_filter_buttons.dart b/lib/new_views/pages/land_page/widgets/static_filter_buttons.dart index 4a04f62c..b0db4bb3 100644 --- a/lib/new_views/pages/land_page/widgets/static_filter_buttons.dart +++ b/lib/new_views/pages/land_page/widgets/static_filter_buttons.dart @@ -11,7 +11,7 @@ class RequestsTypeFilter extends StatefulWidget { final Map items; final List initialValues; - const RequestsTypeFilter({Key key, @required this.items, this.initialValues, this.onSelect}) : super(key: key); + const RequestsTypeFilter({Key? key, required this.items,required this.initialValues,required this.onSelect}) : super(key: key); @override State createState() => _RequestsTypeFilterState(); @@ -70,7 +70,7 @@ class _RequestsTypeFilterState extends State { if (_selected.contains(widget.items[data])) { _selected.remove(widget.items[data]); } else { - _selected.add(widget.items[data]); + _selected.add(widget.items[data]!); } setState(() { widget.onSelect(_selected); diff --git a/lib/new_views/pages/login_page.dart b/lib/new_views/pages/login_page.dart index 0efe789f..445f0b4d 100644 --- a/lib/new_views/pages/login_page.dart +++ b/lib/new_views/pages/login_page.dart @@ -22,7 +22,7 @@ // class LoginPage extends StatefulWidget { // static const String routeName = "/login_page"; // -// const LoginPage({Key key}) : super(key: key); +// const LoginPage({Key? key}) : super(key: key); // // @override // State createState() => _LoginPageState(); @@ -150,7 +150,6 @@ import 'package:test_sa/extensions/text_extensions.dart'; import 'package:test_sa/extensions/widget_extensions.dart'; import 'package:test_sa/new_views/app_style/app_color.dart'; import 'package:test_sa/new_views/pages/land_page/land_page.dart'; -import 'package:test_sa/views/widgets/buttons/rounded_back_button.dart'; import '../../controllers/providers/api/user_provider.dart'; import '../../controllers/providers/settings/setting_provider.dart'; @@ -162,7 +161,7 @@ import '../common_widgets/app_text_form_field.dart'; class LoginPage extends StatefulWidget { static const String routeName = "/login_page"; - const LoginPage({Key key}) : super(key: key); + const LoginPage({Key? key}) : super(key: key); @override State createState() => _LoginPageState(); @@ -170,8 +169,8 @@ class LoginPage extends StatefulWidget { class _LoginPageState extends State { final User _user = User(); - UserProvider _userProvider; - SettingProvider _settingProvider; + late UserProvider _userProvider; + SettingProvider? _settingProvider; final GlobalKey _formKey = GlobalKey(); bool rememberMe = false; @@ -181,10 +180,10 @@ class _LoginPageState extends State { _userProvider = Provider.of(context); if (_settingProvider == null) { _settingProvider = Provider.of(context); - rememberMe = _settingProvider.rememberMe; + rememberMe = _settingProvider!.rememberMe; if (rememberMe) { - _user.userName = _settingProvider.username; - _user.password = _settingProvider.password; + _user.userName = _settingProvider!.username; + _user.password = _settingProvider!.password; } } @@ -235,7 +234,9 @@ class _LoginPageState extends State { ], ), ), - SizedBox(height: 47.toScreenHeight,), + SizedBox( + height: 47.toScreenHeight, + ), Padding( padding: EdgeInsets.symmetric(horizontal: 16.toScreenWidth), child: Column( @@ -243,10 +244,9 @@ class _LoginPageState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ AppTextFormField( - initialValue: _user?.userName, - //TODO add the color according to theme.... + initialValue: _user.userName ?? "", backgroundColor: AppColor.white20, - validator: (value) => Validator.hasValue(value) ? null : context.translation.requiredField, + validator: (value) => Validator.hasValue(value!) ? null : context.translation.requiredField, labelText: context.translation.username, textInputType: TextInputType.text, showWithoutDecoration: true, @@ -257,14 +257,13 @@ class _LoginPageState extends State { ), 18.height, AppTextFormField( - initialValue: _user?.password, + initialValue: _user.password ?? "", showWithoutDecoration: true, labelText: context.translation.password, - //TODO add the color according to theme.... backgroundColor: AppColor.white20, contentPadding: EdgeInsets.symmetric(horizontal: 16.toScreenWidth, vertical: 20.toScreenHeight), obscureText: true, - validator: (value) => Validator.isValidPassword(value) + validator: (value) => Validator.isValidPassword(value!) ? null : value.isEmpty ? context.translation.requiredField @@ -290,14 +289,14 @@ class _LoginPageState extends State { activeColor: AppColor.blueStatus(context), onChanged: (value) { setState(() { - rememberMe = value; + rememberMe = value!; }); }), "Remember Me".bodyText(context).custom(color: context.isDark ? AppColor.primary50 : AppColor.neutral50).expanded, ], ), 50.height, - AppFilledButton(label: context.translation.signIn,buttonColor: AppColor.primary10, maxWidth: true, onPressed: _login), + AppFilledButton(label: context.translation.signIn, buttonColor: AppColor.primary10, maxWidth: true, onPressed: _login), ], ), ), @@ -308,13 +307,13 @@ class _LoginPageState extends State { } Future _login() async { - if (!_formKey.currentState.validate()) return; - _formKey.currentState.save(); + if (!_formKey.currentState!.validate()) return; + _formKey.currentState!.save(); int status = await _userProvider.login(context: context, user: _user); - if (status >= 200 && status < 300 && _userProvider.user.isAuthenticated ?? false) { - await _settingProvider.setUser(_userProvider.user); + if (status >= 200 && status < 300 && _userProvider.user!.isAuthenticated! ?? false) { + await _settingProvider!.setUser(_userProvider.user!); (await SharedPreferences.getInstance()).remove(ASettings.localAuth); - await _settingProvider.setRememberMe(_user.userName, _user.password, rememberMe); + await _settingProvider!.setRememberMe(_user.userName!, _user.password!, rememberMe); /// The below line for the new design // Navigator.pushNamed(context, LandPage.routeName); diff --git a/lib/new_views/pages/new_gas_refill_request_page.dart b/lib/new_views/pages/new_gas_refill_request_page.dart index 39c03895..8084ed63 100644 --- a/lib/new_views/pages/new_gas_refill_request_page.dart +++ b/lib/new_views/pages/new_gas_refill_request_page.dart @@ -29,17 +29,17 @@ import '../common_widgets/default_app_bar.dart'; class NewGasRefillRequestPage extends StatefulWidget { static const String routeName = "/new_gas_refill_request_page"; - const NewGasRefillRequestPage({Key key}) : super(key: key); + const NewGasRefillRequestPage({Key? key}) : super(key: key); @override State createState() => _NewGasRefillRequestPageState(); } class _NewGasRefillRequestPageState extends State { - GasRefillDetails _currentDetails; - GasRefillModel _gasModel; - GlobalKey _formKey; - TextEditingController _quantityController; + late GasRefillDetails _currentDetails; + late GasRefillModel _gasModel; + late GlobalKey _formKey; + late TextEditingController _quantityController; @override void initState() { @@ -81,7 +81,7 @@ class _NewGasRefillRequestPageState extends State { controller: _quantityController, labelText: context.translation.quantity, textInputType: TextInputType.number, - validator: (value) => Validator.hasValue(value) + validator: (value) => Validator.hasValue(value!) ? Validator.isNumeric(value) ? null : context.translation.onlyNumbers @@ -116,9 +116,9 @@ class _NewGasRefillRequestPageState extends State { onSelect: (value) { setState(() { _gasModel.site = value; - _gasModel?.building = null; - _gasModel?.floor = null; - _gasModel?.department = null; + _gasModel.building = null; + _gasModel.floor = null; + _gasModel.department = null; }); }, ), @@ -132,8 +132,8 @@ class _NewGasRefillRequestPageState extends State { onSelect: (value) { setState(() { _gasModel.building = value; - _gasModel?.floor = null; - _gasModel?.department = null; + _gasModel.floor = null; + _gasModel.department = null; }); }, ), @@ -147,7 +147,7 @@ class _NewGasRefillRequestPageState extends State { onSelect: (value) { setState(() { _gasModel.floor = value; - _gasModel?.department = null; + _gasModel.department = null; }); }, ), @@ -187,11 +187,11 @@ class _NewGasRefillRequestPageState extends State { Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - _gasModel.gazRefillDetails[index].gasType?.name?.heading5(context), + (_gasModel.gazRefillDetails![index].gasType?.name ?? "").heading5(context), 8.height, - ("${context.translation.quantity}: ${_gasModel.gazRefillDetails[index].requestedQty}").bodyText(context), - ("${context.translation.cylinderSize}: ${_gasModel.gazRefillDetails[index].cylinderSize?.name}").bodyText(context), - ("${context.translation.cylinderType}: ${_gasModel.gazRefillDetails[index].cylinderType?.name}").bodyText(context), + ("${context.translation.quantity}: ${_gasModel.gazRefillDetails![index].requestedQty}").bodyText(context), + ("${context.translation.cylinderSize}: ${_gasModel.gazRefillDetails![index].cylinderSize?.name}").bodyText(context), + ("${context.translation.cylinderType}: ${_gasModel.gazRefillDetails![index].cylinderType?.name}").bodyText(context), ], ), Container( @@ -241,9 +241,9 @@ class _NewGasRefillRequestPageState extends State { } void _add() async { - if (_formKey.currentState.validate() && await _currentDetails.validate(context) && await _gasModel.validate(context)) { - _formKey.currentState.save(); - _gasModel.gazRefillDetails.add(_currentDetails); + if (_formKey.currentState!.validate() && await _currentDetails.validate(context) && await _gasModel.validate(context)) { + _formKey.currentState!.save(); + _gasModel.gazRefillDetails!.add(_currentDetails); _quantityController.clear(); _currentDetails = GasRefillDetails(); setState(() {}); @@ -251,7 +251,7 @@ class _NewGasRefillRequestPageState extends State { } void _delete(index) { - _gasModel.gazRefillDetails.remove(_gasModel.gazRefillDetails[index]); + _gasModel.gazRefillDetails!.remove(_gasModel.gazRefillDetails![index]); setState(() {}); } @@ -262,7 +262,7 @@ class _NewGasRefillRequestPageState extends State { } await Provider.of(context, listen: false).createModel( context: context, - user: Provider.of(context, listen: false).user, + user: Provider.of(context, listen: false).user!, model: _gasModel, ); } diff --git a/lib/new_views/pages/report_bug_page.dart b/lib/new_views/pages/report_bug_page.dart index e374893a..f7df033b 100644 --- a/lib/new_views/pages/report_bug_page.dart +++ b/lib/new_views/pages/report_bug_page.dart @@ -5,6 +5,7 @@ import 'package:test_sa/extensions/context_extension.dart'; import 'package:test_sa/extensions/int_extensions.dart'; import 'package:test_sa/extensions/text_extensions.dart'; import 'package:test_sa/extensions/widget_extensions.dart'; +import 'package:test_sa/models/user.dart'; import 'package:test_sa/new_views/common_widgets/app_filled_button.dart'; import '../../controllers/providers/api/user_provider.dart'; @@ -13,11 +14,11 @@ import '../common_widgets/default_app_bar.dart'; class ReportBugPage extends StatelessWidget { static const id = "/report_bug_page"; - const ReportBugPage({Key key}) : super(key: key); + const ReportBugPage({Key? key}) : super(key: key); @override Widget build(BuildContext context) { - final user = Provider.of(context, listen: false).user; + final User user = Provider.of(context, listen: false).user!; return Scaffold( appBar: const DefaultAppBar(title: "Survey"), body: Column( @@ -30,7 +31,7 @@ class ReportBugPage extends StatelessWidget { mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - user.clientName.heading5(context), + user.clientName!.heading5(context), 8.height, "Call ID: ${0}".bodyText(context), "Date of Survey: ${DateFormat("dd MMM, yyyy").format(DateTime.now())}".bodyText(context), diff --git a/lib/new_views/pages/settings_page.dart b/lib/new_views/pages/settings_page.dart index 52990914..33921c99 100644 --- a/lib/new_views/pages/settings_page.dart +++ b/lib/new_views/pages/settings_page.dart @@ -3,6 +3,9 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_advanced_switch/flutter_advanced_switch.dart'; import 'package:local_auth/local_auth.dart'; +import 'package:local_auth_android/local_auth_android.dart'; +import 'package:local_auth_darwin/local_auth_darwin.dart'; + import 'package:provider/provider.dart'; import 'package:test_sa/controllers/providers/settings/setting_provider.dart'; import 'package:test_sa/extensions/context_extension.dart'; @@ -10,22 +13,21 @@ import 'package:test_sa/extensions/int_extensions.dart'; import 'package:test_sa/extensions/text_extensions.dart'; import 'package:test_sa/extensions/widget_extensions.dart'; import 'package:test_sa/new_views/app_style/app_color.dart'; -import 'package:local_auth_android/local_auth_android.dart'; -import 'package:local_auth_ios/local_auth_ios.dart'; + import '../common_widgets/default_app_bar.dart'; class SettingsPage extends StatefulWidget { static const id = "/settings_page"; - const SettingsPage({Key key}) : super(key: key); + const SettingsPage({Key? key}) : super(key: key); @override State createState() => _SettingsPageState(); } class _SettingsPageState extends State { - ValueNotifier langController, themeController; - SettingProvider _settingProvider; + ValueNotifier? langController, themeController; + SettingProvider? _settingProvider; bool localAuth = false; @@ -38,26 +40,19 @@ class _SettingsPageState extends State { @override void dispose() { super.dispose(); - langController.dispose(); - themeController.dispose(); + langController?.dispose(); + themeController?.dispose(); // authController.dispose(); } void checkForLocalAuth(bool buttonState) async { - bool authStatus = await _settingProvider.auth.authenticate( + bool authStatus = await _settingProvider!.auth.authenticate( localizedReason: Platform.isAndroid ? "Scan your fingerprint to authenticate" : "Scan with face id to authenticate", options: AuthenticationOptions(), - authMessages: [ - IOSAuthMessages( - cancelButton: 'cancel', - goToSettingsButton: 'settings', - goToSettingsDescription: 'Please enable Touch ID.', - lockOut: 'Please reenable your Touch ID') - ] - ); + authMessages: [IOSAuthMessages(cancelButton: 'cancel', goToSettingsButton: 'settings', goToSettingsDescription: 'Please enable Touch ID.', lockOut: 'Please reenable your Touch ID')]); if (authStatus) { localAuth = !localAuth; - await _settingProvider.setAuth(localAuth); + await _settingProvider!.setAuth(localAuth); // authController.value = _settingProvider.localAuth == buttonState.toString(); setState(() {}); } else { @@ -69,19 +64,19 @@ class _SettingsPageState extends State { Widget build(BuildContext context) { if (_settingProvider == null) { _settingProvider = Provider.of(context, listen: false); - localAuth = _settingProvider.localAuth; + localAuth = _settingProvider!.localAuth; } - langController ??= ValueNotifier(_settingProvider.language == "ar") + langController ??= ValueNotifier(_settingProvider!.language == "ar") ..addListener(() async { /// TODO : uncomment the below lines to support the another language - await _settingProvider.setLanguage(_settingProvider.language == "ar" ? "en" : "ar"); - langController.value = _settingProvider.language == "ar"; + await _settingProvider!.setLanguage(_settingProvider!.language == "ar" ? "en" : "ar"); + langController!.value = _settingProvider!.language == "ar"; }); - themeController ??= ValueNotifier(_settingProvider.theme == "light") + themeController ??= ValueNotifier(_settingProvider!.theme == "light") ..addListener(() async { - await _settingProvider.setDarkTheme(_settingProvider.theme == "light"); - themeController.value = _settingProvider.theme == "light"; + await _settingProvider!.setDarkTheme(_settingProvider!.theme == "light"); + themeController!.value = _settingProvider!.theme == "light"; }); // authController ??= ValueNotifier(_settingProvider.localAuth == "false") @@ -109,7 +104,7 @@ class _SettingsPageState extends State { controller: langController, activeColor: AppColor.green50.withOpacity(0.5), inactiveColor: AppColor.neutral10, - thumb: CircleAvatar(backgroundColor: _settingProvider.language == "ar" ? AppColor.green50 : AppColor.neutral20), + thumb: CircleAvatar(backgroundColor: _settingProvider!.language == "ar" ? AppColor.green50 : AppColor.neutral20), borderRadius: const BorderRadius.all(Radius.circular(30)), width: 42.toScreenWidth, height: 24.toScreenHeight, @@ -131,7 +126,7 @@ class _SettingsPageState extends State { controller: themeController, activeColor: AppColor.green50.withOpacity(0.5), inactiveColor: AppColor.neutral10, - thumb: CircleAvatar(backgroundColor: _settingProvider.theme == "light" ? AppColor.green50 : AppColor.neutral20), + thumb: CircleAvatar(backgroundColor: _settingProvider!.theme == "light" ? AppColor.green50 : AppColor.neutral20), borderRadius: const BorderRadius.all(Radius.circular(30)), width: 42.toScreenWidth, height: 24.toScreenHeight, @@ -143,11 +138,11 @@ class _SettingsPageState extends State { const Divider().defaultStyle(context), 16.height, FutureBuilder( - future: _settingProvider.auth.isDeviceSupported(), + future: _settingProvider!.auth.isDeviceSupported(), builder: (cxt, snapshot) { bool isDeviceSupported = false; if (snapshot.hasData) { - isDeviceSupported = snapshot.data; + isDeviceSupported = snapshot.data as bool; } if (!isDeviceSupported) { diff --git a/lib/new_views/pages/splash_page.dart b/lib/new_views/pages/splash_page.dart index 9b5d0e36..b0941c48 100644 --- a/lib/new_views/pages/splash_page.dart +++ b/lib/new_views/pages/splash_page.dart @@ -16,15 +16,15 @@ import '../../models/size_config.dart'; class SplashPage extends StatefulWidget { static const String routeName = '/splash_page'; - const SplashPage({Key key}) : super(key: key); + const SplashPage({Key? key}) : super(key: key); @override State createState() => _SplashPageState(); } class _SplashPageState extends State { - SettingProvider _settingProvider; - UserProvider _userProvider; + late SettingProvider _settingProvider; + late UserProvider _userProvider; bool loading = false; @@ -61,7 +61,7 @@ class _SplashPageState extends State { if (isValid && _settingProvider.isLocalAuthEnable) { bool isSuccess = await checkDualAuthentication(); if (isSuccess) { - _userProvider.user = _settingProvider.user; + _userProvider.setUser(_settingProvider.user!); Navigator.of(context).pushNamedAndRemoveUntil(LandPage.routeName, (routes) => true); } else { Navigator.of(context).pushNamedAndRemoveUntil(LoginPage.routeName, (routes) => true); @@ -106,7 +106,7 @@ class _SplashPageState extends State { animation: "splash", callback: (animation) async { if (_settingProvider.isLoaded && (_settingProvider.user != null)) { - checkTokenValidity(_settingProvider.user.token); + checkTokenValidity(_settingProvider.user!.token!); } else { Navigator.of(context).pushNamedAndRemoveUntil(LoginPage.routeName, (routes) => true); } diff --git a/lib/providers/loading_list_notifier.dart b/lib/providers/loading_list_notifier.dart index 45a83784..703fdc82 100644 --- a/lib/providers/loading_list_notifier.dart +++ b/lib/providers/loading_list_notifier.dart @@ -9,7 +9,7 @@ class NullableLoadingProvider extends LoadingListNotifier { } abstract class LoadingListNotifier extends ChangeNotifier { - int stateCode; + int? stateCode; List items = []; @@ -23,8 +23,8 @@ abstract class LoadingListNotifier extends ChangeNotifier { } void reset() { - items = null; - _loading = null; + items = []; + _loading = false; stateCode = null; } diff --git a/lib/providers/work_order/reason_provider.dart b/lib/providers/work_order/reason_provider.dart index bd53bf99..31bf2ba6 100644 --- a/lib/providers/work_order/reason_provider.dart +++ b/lib/providers/work_order/reason_provider.dart @@ -8,8 +8,8 @@ import '../../controllers/api_routes/urls.dart'; import '../../models/lookup.dart'; class ReasonProvider extends LoadingListNotifier { + String? serviceRequestId; - String serviceRequestId; @override Future getDate() async { if (loading == true) return -2; @@ -18,7 +18,7 @@ class ReasonProvider extends LoadingListNotifier { loading = true; notifyListeners(); try { - Response response = await ApiManager.instance.get(URLs.getServiceReportReasons+"&serviceRequestId=$serviceRequestId"); + Response response = await ApiManager.instance.get(URLs.getServiceReportReasons + "&serviceRequestId=$serviceRequestId"); stateCode = response.statusCode; if (response.statusCode >= 200 && response.statusCode < 300) { // client's request was successfully received diff --git a/lib/service_request_latest/views/components/activities_list_view.dart b/lib/service_request_latest/views/components/activities_list_view.dart index c654cf9e..60144d52 100644 --- a/lib/service_request_latest/views/components/activities_list_view.dart +++ b/lib/service_request_latest/views/components/activities_list_view.dart @@ -12,9 +12,7 @@ import 'package:test_sa/models/service_request/search_work_order.dart'; import 'package:test_sa/new_views/app_style/app_color.dart'; import 'package:test_sa/new_views/common_widgets/app_filled_button.dart'; import 'package:test_sa/new_views/common_widgets/default_app_bar.dart'; -import 'package:test_sa/service_request_latest/views/components/bottom_sheets/activity_type_bottomsheet.dart'; import 'package:test_sa/service_request_latest/views/components/bottom_sheets/service_request_bottomsheet.dart'; -import 'package:test_sa/views/pages/user/requests/work_order/create_service_report.dart'; import 'package:test_sa/views/pages/user/requests/work_order/update_service_report.dart'; import 'package:test_sa/views/pages/user/requests/work_order/work_order_details_page.dart'; import 'package:test_sa/views/widgets/loaders/no_item_found.dart'; @@ -23,7 +21,7 @@ import 'package:test_sa/views/widgets/requests/request_status.dart'; class ActivitiesListView extends StatelessWidget { static const String id = "/activities-list"; - ActivitiesListView({Key key}) : super(key: key); + ActivitiesListView({Key? key}) : super(key: key); @override Widget build(BuildContext context) { @@ -37,7 +35,7 @@ class ActivitiesListView extends StatelessWidget { body: Consumer(builder: (context, serviceRequestsProvider, child) { return SafeArea( child: FutureBuilder( - future: serviceRequestsProvider.searchWorkOrders(callId: serviceRequestsProvider.currentSelectedRequest?.requestCode), + future: serviceRequestsProvider.searchWorkOrders(callId: serviceRequestsProvider.currentSelectedRequest.requestCode!), builder: (context, snap) { if (snap.connectionState == ConnectionState.waiting) return const Center(child: CircularProgressIndicator()); workOrders = snap.data as List; @@ -58,18 +56,19 @@ class ActivitiesListView extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ StatusLabel( - label: workOrders[index].currentSituation.name, - textColor: AppColor.getRequestStatusTextColorByName(context, workOrders[index].currentSituation.name), - backgroundColor: AppColor.getRequestStatusColorByName(context, workOrders[index].currentSituation.name), + label: workOrders[index].currentSituation!.name, + textColor: AppColor.getRequestStatusTextColorByName(context, workOrders[index].currentSituation!.name!), + backgroundColor: AppColor.getRequestStatusColorByName(context, workOrders[index].currentSituation!.name!), ), 8.height, - Text(serviceRequestsProvider.currentSelectedRequest.requestCode, style: AppTextStyles.heading5.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50)), + Text(serviceRequestsProvider.currentSelectedRequest.requestCode!, + style: AppTextStyles.heading5.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50)), Text( - '${context.translation.assetName}: ${workOrders[index].callRequest.asset.modelDefinition.assetName?.cleanupWhitespace?.capitalizeFirstOfEach}', + '${context.translation.assetName}: ${workOrders[index].callRequest!.asset!.modelDefinition!.assetName?.cleanupWhitespace?.capitalizeFirstOfEach}', style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20), ), Text( - '${context.translation.currentSituation}: ${workOrders[index].currentSituation.name}', + '${context.translation.currentSituation}: ${workOrders[index].currentSituation!.name}', style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20), ), 16.height, @@ -95,7 +94,7 @@ class ActivitiesListView extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.start, children: [ - if (_userProvider.user.type == UsersTypes.engineer && + if (_userProvider.user!.type == UsersTypes.engineer && serviceRequestsProvider.currentSelectedRequest.statusValue != 5 && serviceRequestsProvider.currentSelectedRequest.statusValue != 3) "edit".toSvgAsset(height: 48, width: 48).onPress(() { @@ -103,7 +102,7 @@ class ActivitiesListView extends StatelessWidget { MaterialPageRoute(builder: (_) => UpdateServiceReport(request: serviceRequestsProvider.currentSelectedRequest, workOrder: workOrders[index])), ); }), - if (_userProvider.user.type == UsersTypes.engineer && + if (_userProvider.user!.type == UsersTypes.engineer && serviceRequestsProvider.currentSelectedRequest.statusValue != 5 && serviceRequestsProvider.currentSelectedRequest.statusValue != 3) 8.height, @@ -115,11 +114,12 @@ class ActivitiesListView extends StatelessWidget { ).toShadowContainer(context); }, ).expanded, - if (_userProvider.user.type == UsersTypes.engineer && (serviceRequestsProvider.currentSelectedRequest.statusValue != 5 && serviceRequestsProvider.currentSelectedRequest.statusValue != 3)) + if (_userProvider.user!.type == UsersTypes.engineer && + (serviceRequestsProvider.currentSelectedRequest.statusValue != 5 && serviceRequestsProvider.currentSelectedRequest.statusValue != 3)) AppFilledButton( label: context.translation.createNewActivity, maxWidth: true, - onPressed: () async{ + onPressed: () async { ServiceRequestBottomSheet.fixRemotelyBottomSheet(context: context); // bool shouldReloadData = (await showModalBottomSheet( // context: context, diff --git a/lib/service_request_latest/views/components/activity_card_view.dart b/lib/service_request_latest/views/components/activity_card_view.dart index 1665ad0a..45336f03 100644 --- a/lib/service_request_latest/views/components/activity_card_view.dart +++ b/lib/service_request_latest/views/components/activity_card_view.dart @@ -21,7 +21,7 @@ class ActivityCardView extends StatelessWidget { final ServiceRequest serviceRequest; final bool showShadow; - ActivityCardView(this.workOrder, this.serviceRequest, {Key key, this.showShadow = true}) : super(key: key); + ActivityCardView(this.workOrder, this.serviceRequest, {Key? key, this.showShadow = true}) : super(key: key); @override Widget build(BuildContext context) { @@ -34,18 +34,18 @@ class ActivityCardView extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ StatusLabel( - label: workOrder.currentSituation.name, - textColor: AppColor.getRequestStatusTextColorByName(context, workOrder.currentSituation.name), - backgroundColor: AppColor.getRequestStatusColorByName(context, workOrder.currentSituation.name), + label: workOrder.currentSituation!.name, + textColor: AppColor.getRequestStatusTextColorByName(context, workOrder.currentSituation!.name!), + backgroundColor: AppColor.getRequestStatusColorByName(context, workOrder.currentSituation!.name!), ), 8.height, - Text(serviceRequest.requestCode, style: AppTextStyles.heading5.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50)), + Text(serviceRequest.requestCode!, style: AppTextStyles.heading5.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50)), Text( - '${context.translation.assetName}: ${workOrder.callRequest.asset.modelDefinition.assetName?.cleanupWhitespace?.capitalizeFirstOfEach}', + '${context.translation.assetName}: ${workOrder.callRequest!.asset!.modelDefinition!.assetName?.cleanupWhitespace?.capitalizeFirstOfEach}', style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20), ), Text( - '${context.translation.currentSituation}: ${workOrder.currentSituation.name}', + '${context.translation.currentSituation}: ${workOrder.currentSituation!.name}', style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20), ), 16.height, @@ -71,13 +71,13 @@ class ActivityCardView extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.start, children: [ - if (_userProvider.user.type == UsersTypes.engineer && serviceRequest.statusValue != 5 && serviceRequest.statusValue != 3) + if (_userProvider.user!.type == UsersTypes.engineer && serviceRequest.statusValue != 5 && serviceRequest.statusValue != 3) "edit_icon".toSvgAsset(height: 21, width: 21).onPress(() { Navigator.of(context).push( MaterialPageRoute(builder: (_) => UpdateServiceReport(request: serviceRequest, workOrder: workOrder)), ); }), - if (_userProvider.user.type == UsersTypes.engineer && serviceRequest.statusValue != 5 && serviceRequest.statusValue != 3) 8.height, + if (_userProvider.user!.type == UsersTypes.engineer && serviceRequest.statusValue != 5 && serviceRequest.statusValue != 3) 8.height, Text(workOrder.visitDate?.toServiceRequestCardFormat ?? "", textAlign: TextAlign.end, style: AppTextStyles.tinyFont.copyWith(color: context.isDark ? AppColor.neutral30 : const Color(0xFF3B3D4A))), ], diff --git a/lib/service_request_latest/views/components/bottom_sheets/action_bottomsheet.dart b/lib/service_request_latest/views/components/bottom_sheets/action_bottomsheet.dart index e7c1e563..4996ba70 100644 --- a/lib/service_request_latest/views/components/bottom_sheets/action_bottomsheet.dart +++ b/lib/service_request_latest/views/components/bottom_sheets/action_bottomsheet.dart @@ -1,89 +1,84 @@ -import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; -import 'package:test_sa/controllers/providers/api/user_provider.dart'; -import 'package:test_sa/controllers/providers/settings/setting_provider.dart'; -import 'package:test_sa/extensions/context_extension.dart'; -import 'package:test_sa/extensions/int_extensions.dart'; -import 'package:test_sa/extensions/string_extensions.dart'; -import 'package:test_sa/extensions/text_extensions.dart'; -import 'package:test_sa/extensions/widget_extensions.dart'; -import 'package:test_sa/service_request_latest/views/components/verify_arrival_view.dart'; -import 'package:test_sa/views/widgets/date_and_time/date_picker.dart'; -import '../../../../controllers/providers/api/service_requests_provider.dart'; -import '../../../../new_views/app_style/app_color.dart'; -import '../../../../new_views/common_widgets/app_filled_button.dart'; -import '../../../../new_views/common_widgets/app_text_form_field.dart'; - -class ActionBottomSheet extends StatelessWidget { - final String title; - final String button1Text; - final String button2Text; - final VoidCallback button1Tap; - final VoidCallback button2Tap; - - ActionBottomSheet({Key key, @required this.title, this.button1Text, this.button2Text, this.button1Tap, this.button2Tap}) : super(key: key); - - final GlobalKey _formKey = GlobalKey(); - - @override - Widget build(BuildContext context) { - return Consumer(builder: (context, serviceRequestProvider, child) { - return Wrap( - children: [ - Container( - clipBehavior: Clip.antiAlias, - margin: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom), - decoration: BoxDecoration( - color: Theme.of(context).scaffoldBackgroundColor, - borderRadius: const BorderRadius.only(topRight: Radius.circular(20), topLeft: Radius.circular(20)), - ), - padding: EdgeInsets.symmetric(horizontal: 16.toScreenWidth, vertical: 8.toScreenHeight), - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Container( - width: 40.toScreenWidth, - height: 5.toScreenHeight, - decoration: BoxDecoration(color: AppColor.neutral40, borderRadius: BorderRadius.circular(30)), - ), - Align( - alignment: AlignmentDirectional.centerStart, - child: title.heading4(context).custom(fontWeight: FontWeight.w500).paddingOnly(top: 16, bottom: 16), - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - SizedBox( - width: 200.toScreenHeight, - child: AppFilledButton( - label: button1Text ?? context.translation.no, - loading: false, - buttonColor: AppColor.neutral40, - textColor: AppColor.black10, - onPressed: button1Tap ?? - () async { - Navigator.pop(context); - // await snapshot.updateRequest(user: userProvider.user, request: serviceRequestProvider.serviceRequest); - // Navigator.pop(context, true); - }, - ), - ), - SizedBox( - width: 200.toScreenHeight, - child: AppFilledButton( - label: context.translation.yes, - buttonColor: AppColor.primary10, - loading: false, - onPressed:button2Tap, - ), - ), - ], - ) - ], - ), - ) - ], - ); - }); - } -} +// import 'package:flutter/material.dart'; +// import 'package:provider/provider.dart'; +// import 'package:test_sa/extensions/context_extension.dart'; +// import 'package:test_sa/extensions/int_extensions.dart'; +// import 'package:test_sa/extensions/text_extensions.dart'; +// import 'package:test_sa/extensions/widget_extensions.dart'; +// +// import '../../../../controllers/providers/api/service_requests_provider.dart'; +// import '../../../../new_views/app_style/app_color.dart'; +// import '../../../../new_views/common_widgets/app_filled_button.dart'; +// +// class ActionBottomSheet extends StatelessWidget { +// final String title; +// final String button1Text; +// final String button2Text; +// final VoidCallback button1Tap; +// final VoidCallback button2Tap; +// +// ActionBottomSheet({Key? key, required this.title, this.button1Text, this.button2Text, this.button1Tap, this.button2Tap}) : super(key: key); +// +// final GlobalKey _formKey = GlobalKey(); +// +// @override +// Widget build(BuildContext context) { +// return Consumer(builder: (context, serviceRequestProvider, child) { +// return Wrap( +// children: [ +// Container( +// clipBehavior: Clip.antiAlias, +// margin: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom), +// decoration: BoxDecoration( +// color: Theme.of(context).scaffoldBackgroundColor, +// borderRadius: const BorderRadius.only(topRight: Radius.circular(20), topLeft: Radius.circular(20)), +// ), +// padding: EdgeInsets.symmetric(horizontal: 16.toScreenWidth, vertical: 8.toScreenHeight), +// child: Column( +// mainAxisSize: MainAxisSize.min, +// children: [ +// Container( +// width: 40.toScreenWidth, +// height: 5.toScreenHeight, +// decoration: BoxDecoration(color: AppColor.neutral40, borderRadius: BorderRadius.circular(30)), +// ), +// Align( +// alignment: AlignmentDirectional.centerStart, +// child: title.heading4(context).custom(fontWeight: FontWeight.w500).paddingOnly(top: 16, bottom: 16), +// ), +// Row( +// mainAxisAlignment: MainAxisAlignment.spaceBetween, +// children: [ +// SizedBox( +// width: 200.toScreenHeight, +// child: AppFilledButton( +// label: button1Text ?? context.translation.no, +// loading: false, +// buttonColor: AppColor.neutral40, +// textColor: AppColor.black10, +// onPressed: button1Tap ?? +// () async { +// Navigator.pop(context); +// // await snapshot.updateRequest(user: userProvider.user, request: serviceRequestProvider.serviceRequest); +// // Navigator.pop(context, true); +// }, +// ), +// ), +// SizedBox( +// width: 200.toScreenHeight, +// child: AppFilledButton( +// label: context.translation.yes, +// buttonColor: AppColor.primary10, +// loading: false, +// onPressed: button2Tap, +// ), +// ), +// ], +// ) +// ], +// ), +// ) +// ], +// ); +// }); +// } +// } diff --git a/lib/service_request_latest/views/components/bottom_sheets/activity_type_bottomsheet.dart b/lib/service_request_latest/views/components/bottom_sheets/activity_type_bottomsheet.dart index ed66fe34..7bce4ae2 100644 --- a/lib/service_request_latest/views/components/bottom_sheets/activity_type_bottomsheet.dart +++ b/lib/service_request_latest/views/components/bottom_sheets/activity_type_bottomsheet.dart @@ -9,12 +9,10 @@ import 'package:test_sa/extensions/text_extensions.dart'; import 'package:test_sa/extensions/widget_extensions.dart'; import 'package:test_sa/models/service_request/service_request.dart'; import 'package:test_sa/new_views/app_style/app_color.dart'; -import 'package:test_sa/new_views/common_widgets/default_app_bar.dart'; import 'package:test_sa/service_request_latest/views/components/spare_part_request.dart'; -import 'package:test_sa/views/pages/user/requests/work_order/create_service_report.dart'; class ActivityTypeBottomSheet extends StatelessWidget { - ActivityTypeBottomSheet({Key key}) : super(key: key); + ActivityTypeBottomSheet({Key? key}) : super(key: key); @override Widget build(BuildContext context) { @@ -48,9 +46,9 @@ class ActivityTypeBottomSheet extends StatelessWidget { itemBuilder: (context, index) { final item = items[index]; return listItem( - icon: item['icon'], - heading: item['heading'], - subHeading: item['subHeading'], + icon: item['icon']!, + heading: item['heading']!, + subHeading: item['subHeading']!, context: context, onTap: () { onItemTap(serviceRequest: serviceRequestsProvider.currentSelectedRequest, index: index, context: context); @@ -66,14 +64,14 @@ class ActivityTypeBottomSheet extends StatelessWidget { ); } - Widget listItem({@required BuildContext context, @required String icon, @required String heading, @required String subHeading, @required VoidCallback onTap}) { + Widget listItem({required BuildContext context, required String icon, required String heading, required String subHeading, required VoidCallback onTap}) { return Padding( - padding: EdgeInsets.only(bottom: 8.toScreenHeight), + padding: EdgeInsets.only(bottom: 8.toScreenHeight), child: Card( color: AppColor.neutral80, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(15), - // Circular border radius + // Circular border radius ), // color: Colors.white, child: ListTile( @@ -95,11 +93,11 @@ class ActivityTypeBottomSheet extends StatelessWidget { ); } - void onItemTap({@required int index, @required ServiceRequest serviceRequest, @required BuildContext context}) { + void onItemTap({required int index, required ServiceRequest serviceRequest, required BuildContext context}) { print('on item tap i got index is $index'); switch (index) { case 0: - Navigator.of(context).push(MaterialPageRoute(builder: (_) =>const SparePartRequest())); + Navigator.of(context).push(MaterialPageRoute(builder: (_) => const SparePartRequest())); break; case 1: diff --git a/lib/service_request_latest/views/components/bottom_sheets/initial_visit_bottomsheet.dart b/lib/service_request_latest/views/components/bottom_sheets/initial_visit_bottomsheet.dart index 3c04ce0f..3e48d19a 100644 --- a/lib/service_request_latest/views/components/bottom_sheets/initial_visit_bottomsheet.dart +++ b/lib/service_request_latest/views/components/bottom_sheets/initial_visit_bottomsheet.dart @@ -16,7 +16,7 @@ import '../../../../new_views/common_widgets/app_text_form_field.dart'; class InitialVisitBottomSheet extends StatelessWidget { - InitialVisitBottomSheet({Key key,}) : super(key: key); + InitialVisitBottomSheet({Key? key,}) : super(key: key); final GlobalKey _formKey = GlobalKey(); @@ -71,7 +71,7 @@ class InitialVisitBottomSheet extends StatelessWidget { selectedTime.minute, ); if (selectedDateTime != null) { - if (selectedDateTime.isBefore(DateTime.parse(serviceRequestProvider.currentSelectedRequest.date))) { + if (selectedDateTime.isBefore(DateTime.parse(serviceRequestProvider.currentSelectedRequest.date!))) { "Visit Date time must be greater then request date".showToast; return; } @@ -84,7 +84,7 @@ class InitialVisitBottomSheet extends StatelessWidget { ), // ], - if (serviceRequestProvider.currentSelectedRequest.firstAction?.id == 404 && Provider.of(context, listen: false).assetGroup.id == 1) ...[ + if (serviceRequestProvider.currentSelectedRequest.firstAction?.id == 404 && Provider.of(context, listen: false).assetGroup!.id == 1) ...[ 8.height, Row( children: [ @@ -140,7 +140,7 @@ class InitialVisitBottomSheet extends StatelessWidget { if (selectedDateTime != null) { serviceRequestProvider.currentSelectedRequest.endDate = selectedDateTime?.toIso8601String(); serviceRequestProvider.currentSelectedRequest.workingHours = - (((DateTime.parse(serviceRequestProvider.currentSelectedRequest.endDate).difference(DateTime.parse(serviceRequestProvider.currentSelectedRequest.startDate)).inSeconds ?? 0) / 60) / 60).toStringAsFixed(2); + (((DateTime.parse(serviceRequestProvider.currentSelectedRequest.endDate!).difference(DateTime.parse(serviceRequestProvider.currentSelectedRequest.startDate!)).inSeconds ?? 0) / 60) / 60).toStringAsFixed(2); } } }); @@ -194,7 +194,7 @@ class InitialVisitBottomSheet extends StatelessWidget { label: context.translation.save, loading: snapshot.isLoading ?? false, onPressed: () async { - _formKey.currentState.save(); + _formKey.currentState!.save(); // await snapshot.updateRequest(user: userProvider.user, request: serviceRequestProvider.serviceRequest); // Navigator.pop(context, true); diff --git a/lib/service_request_latest/views/components/bottom_sheets/reject_request_bottomsheet.dart b/lib/service_request_latest/views/components/bottom_sheets/reject_request_bottomsheet.dart index 2566c764..3ff9376c 100644 --- a/lib/service_request_latest/views/components/bottom_sheets/reject_request_bottomsheet.dart +++ b/lib/service_request_latest/views/components/bottom_sheets/reject_request_bottomsheet.dart @@ -6,6 +6,7 @@ import 'package:test_sa/extensions/int_extensions.dart'; import 'package:test_sa/extensions/text_extensions.dart'; import 'package:test_sa/extensions/widget_extensions.dart'; import 'package:test_sa/models/device/asset.dart'; + import '../../../../controllers/providers/api/service_requests_provider.dart'; import '../../../../models/lookup.dart'; import '../../../../new_views/app_style/app_color.dart'; @@ -15,222 +16,220 @@ import '../../../../new_views/common_widgets/single_item_drop_down_menu.dart'; import '../../../../providers/service_request_providers/first_action_provider.dart'; class RejectRequestBottomSheet extends StatelessWidget { - - RejectRequestBottomSheet({Key key,}) : super(key: key); + RejectRequestBottomSheet({ + Key? key, + }) : super(key: key); final GlobalKey _formKey = GlobalKey(); - Asset asset; - + Asset? asset; @override Widget build(BuildContext context) { final userProvider = Provider.of(context, listen: false); - return Consumer( - builder: (context, requestDetailProvider,child) { - return Wrap( - children: [ - Container( - clipBehavior: Clip.antiAlias, - margin: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom), - decoration: BoxDecoration( - color: Theme.of(context).scaffoldBackgroundColor, - borderRadius: const BorderRadius.only(topRight: Radius.circular(20), topLeft: Radius.circular(20)), - ), - padding: EdgeInsets.symmetric(horizontal: 16.toScreenWidth, vertical: 8.toScreenHeight), - child: Form( - key: _formKey, - child: SingleChildScrollView( - child: Column( - children: [ - Container( - width: 40.toScreenWidth, - height: 5.toScreenHeight, - decoration: BoxDecoration(color: AppColor.neutral40, borderRadius: BorderRadius.circular(30)), - ), - Align( - alignment: AlignmentDirectional.centerStart, - child: context.translation.rejectionReason.heading3(context).custom(fontWeight: FontWeight.w600).paddingOnly(top: 16, bottom: 16), - ), - SingleItemDropDownMenu( - context: context, - title: context.translation.rejectionReason, - initialValue: requestDetailProvider.currentSelectedRequest.firstAction, //_currentSelectedRequest.firstAction, - onSelect: (value) { - // setState(() { - //_currentSelectedRequest.firstAction = value; - requestDetailProvider.currentSelectedRequest.firstAction = value; - if (requestDetailProvider.currentSelectedRequest.firstAction.value != 2) { - requestDetailProvider.currentSelectedRequest.visitDate = null; - } - // }); - }, - ), - // if (requestDetailProvider.currentSelectedRequest.firstAction?.value == 2) ...[ - // 8.height, - // ADatePicker( - // label: context.translation.visitDate, - // date: DateTime.tryParse(requestDetailProvider.currentSelectedRequest.visitDate ?? ""), - // formatDateWithTime: true, - // onDatePicker: (selectedDate) { - // if (selectedDate != null) { - // showTimePicker( - // context: context, - // initialTime: TimeOfDay.now(), - // ).then((selectedTime) { - // // Handle the selected date and time here. - // if (selectedTime != null) { - // DateTime selectedDateTime = DateTime( - // selectedDate.year, - // selectedDate.month, - // selectedDate.day, - // selectedTime.hour, - // selectedTime.minute, - // ); - // if (selectedDateTime != null) { - // if (selectedDateTime.isBefore(DateTime.parse(requestDetailProvider.currentSelectedRequest.date))) { - // "Visit Date time must be greater then request date".showToast; - // return; - // } - // - // // setState(() { - // requestDetailProvider.currentSelectedRequest.visitDate = selectedDateTime?.toIso8601String(); - // // }); - // } - // } - // }); - // } - // }, - // ), - // ], - // - // if (requestDetailProvider.currentSelectedRequest.firstAction?.id == 404 && Provider.of(context, listen: false).assetGroup.id == 1) ...[ - // 8.height, - // Row( - // children: [ - // ADatePicker( - // label: context.translation.startDate, - // date: DateTime.tryParse(requestDetailProvider.currentSelectedRequest.startDate ?? ""), - // formatDateWithTime: true, - // onDatePicker: (selectedDate) { - // if (selectedDate != null) { - // showTimePicker( - // context: context, - // initialTime: TimeOfDay.now(), - // ).then((selectedTime) { - // // Handle the selected date and time here. - // if (selectedTime != null) { - // DateTime selectedDateTime = DateTime( - // selectedDate.year, - // selectedDate.month, - // selectedDate.day, - // selectedTime.hour, - // selectedTime.minute, - // ); - // if (selectedDateTime != null) { - // requestDetailProvider.currentSelectedRequest.startDate = selectedDateTime?.toIso8601String(); - // } - // } - // }); - // } - // }, - // ).expanded, - // 8.width, - // ADatePicker( - // label: context.translation.endDate, - // date: DateTime.tryParse(requestDetailProvider.currentSelectedRequest.endDate ?? ""), - // formatDateWithTime: true, - // onDatePicker: (selectedDate) { - // if (selectedDate != null) { - // showTimePicker( - // context: context, - // initialTime: TimeOfDay.now(), - // ).then((selectedTime) { - // // Handle the selected date and time here. - // if (selectedTime != null) { - // DateTime selectedDateTime = DateTime( - // selectedDate.year, - // selectedDate.month, - // selectedDate.day, - // selectedTime.hour, - // selectedTime.minute, - // ); - // if (selectedDateTime != null) { - // requestDetailProvider.currentSelectedRequest.endDate = selectedDateTime?.toIso8601String(); - // requestDetailProvider.currentSelectedRequest.workingHours = - // (((DateTime.parse(requestDetailProvider.currentSelectedRequest.endDate).difference(DateTime.parse(requestDetailProvider.currentSelectedRequest.startDate)).inSeconds ?? 0) / 60) / 60).toStringAsFixed(2); - // } - // } - // }); - // } - // }, - // ).expanded, - // ], - // ) - // ], + return Consumer(builder: (context, requestDetailProvider, child) { + return Wrap( + children: [ + Container( + clipBehavior: Clip.antiAlias, + margin: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom), + decoration: BoxDecoration( + color: Theme.of(context).scaffoldBackgroundColor, + borderRadius: const BorderRadius.only(topRight: Radius.circular(20), topLeft: Radius.circular(20)), + ), + padding: EdgeInsets.symmetric(horizontal: 16.toScreenWidth, vertical: 8.toScreenHeight), + child: Form( + key: _formKey, + child: SingleChildScrollView( + child: Column( + children: [ + Container( + width: 40.toScreenWidth, + height: 5.toScreenHeight, + decoration: BoxDecoration(color: AppColor.neutral40, borderRadius: BorderRadius.circular(30)), + ), + Align( + alignment: AlignmentDirectional.centerStart, + child: context.translation.rejectionReason.heading3(context).custom(fontWeight: FontWeight.w600).paddingOnly(top: 16, bottom: 16), + ), + SingleItemDropDownMenu( + context: context, + title: context.translation.rejectionReason, + initialValue: requestDetailProvider.currentSelectedRequest.firstAction, //_currentSelectedRequest.firstAction, + onSelect: (value) { + // setState(() { + //_currentSelectedRequest.firstAction = value; + requestDetailProvider.currentSelectedRequest.firstAction = value; + if (requestDetailProvider.currentSelectedRequest.firstAction!.value != 2) { + requestDetailProvider.currentSelectedRequest.visitDate = null; + } + // }); + }, + ), + // if (requestDetailProvider.currentSelectedRequest.firstAction?.value == 2) ...[ + // 8.height, + // ADatePicker( + // label: context.translation.visitDate, + // date: DateTime.tryParse(requestDetailProvider.currentSelectedRequest.visitDate ?? ""), + // formatDateWithTime: true, + // onDatePicker: (selectedDate) { + // if (selectedDate != null) { + // showTimePicker( + // context: context, + // initialTime: TimeOfDay.now(), + // ).then((selectedTime) { + // // Handle the selected date and time here. + // if (selectedTime != null) { + // DateTime selectedDateTime = DateTime( + // selectedDate.year, + // selectedDate.month, + // selectedDate.day, + // selectedTime.hour, + // selectedTime.minute, + // ); + // if (selectedDateTime != null) { + // if (selectedDateTime.isBefore(DateTime.parse(requestDetailProvider.currentSelectedRequest.date))) { + // "Visit Date time must be greater then request date".showToast; + // return; + // } + // + // // setState(() { + // requestDetailProvider.currentSelectedRequest.visitDate = selectedDateTime?.toIso8601String(); + // // }); + // } + // } + // }); + // } + // }, + // ), + // ], + // + // if (requestDetailProvider.currentSelectedRequest.firstAction?.id == 404 && Provider.of(context, listen: false).assetGroup.id == 1) ...[ + // 8.height, + // Row( + // children: [ + // ADatePicker( + // label: context.translation.startDate, + // date: DateTime.tryParse(requestDetailProvider.currentSelectedRequest.startDate ?? ""), + // formatDateWithTime: true, + // onDatePicker: (selectedDate) { + // if (selectedDate != null) { + // showTimePicker( + // context: context, + // initialTime: TimeOfDay.now(), + // ).then((selectedTime) { + // // Handle the selected date and time here. + // if (selectedTime != null) { + // DateTime selectedDateTime = DateTime( + // selectedDate.year, + // selectedDate.month, + // selectedDate.day, + // selectedTime.hour, + // selectedTime.minute, + // ); + // if (selectedDateTime != null) { + // requestDetailProvider.currentSelectedRequest.startDate = selectedDateTime?.toIso8601String(); + // } + // } + // }); + // } + // }, + // ).expanded, + // 8.width, + // ADatePicker( + // label: context.translation.endDate, + // date: DateTime.tryParse(requestDetailProvider.currentSelectedRequest.endDate ?? ""), + // formatDateWithTime: true, + // onDatePicker: (selectedDate) { + // if (selectedDate != null) { + // showTimePicker( + // context: context, + // initialTime: TimeOfDay.now(), + // ).then((selectedTime) { + // // Handle the selected date and time here. + // if (selectedTime != null) { + // DateTime selectedDateTime = DateTime( + // selectedDate.year, + // selectedDate.month, + // selectedDate.day, + // selectedTime.hour, + // selectedTime.minute, + // ); + // if (selectedDateTime != null) { + // requestDetailProvider.currentSelectedRequest.endDate = selectedDateTime?.toIso8601String(); + // requestDetailProvider.currentSelectedRequest.workingHours = + // (((DateTime.parse(requestDetailProvider.currentSelectedRequest.endDate).difference(DateTime.parse(requestDetailProvider.currentSelectedRequest.startDate)).inSeconds ?? 0) / 60) / 60).toStringAsFixed(2); + // } + // } + // }); + // } + // }, + // ).expanded, + // ], + // ) + // ], - /// Loan availability not required - // 8.height, - // SingleItemDropDownMenu( - // context: context, - // title: context.translation.loanAvailability, - // initialValue: _currentSelectedRequest.loanAvailability, - // onSelect: (status) { - // setState(() { - // _currentSelectedRequest.loanAvailability = status; - // if (_currentSelectedRequest.loanAvailability.value != 1) { - // asset = null; - // } - // }); - // }, - // ), - // if (_currentSelectedRequest?.loanAvailability?.value == 1) 8.height, - // if (_currentSelectedRequest?.loanAvailability?.value == 1) - // PickAsset( - // device: asset ?? _currentSelectedRequest.device, - // onPickAsset: (asset) { - // setState(() { - // this.asset = asset; - // }); - // }, - // ), - 8.height, - AppTextFormField( - labelText: context.translation.comments, - textInputType: TextInputType.multiline, - alignLabelWithHint: true, - onChange: (text) { - requestDetailProvider.currentSelectedRequest.comments = text; + /// Loan availability not required + // 8.height, + // SingleItemDropDownMenu( + // context: context, + // title: context.translation.loanAvailability, + // initialValue: _currentSelectedRequest.loanAvailability, + // onSelect: (status) { + // setState(() { + // _currentSelectedRequest.loanAvailability = status; + // if (_currentSelectedRequest.loanAvailability.value != 1) { + // asset = null; + // } + // }); + // }, + // ), + // if (_currentSelectedRequest?.loanAvailability?.value == 1) 8.height, + // if (_currentSelectedRequest?.loanAvailability?.value == 1) + // PickAsset( + // device: asset ?? _currentSelectedRequest.device, + // onPickAsset: (asset) { + // setState(() { + // this.asset = asset; + // }); + // }, + // ), + 8.height, + AppTextFormField( + labelText: context.translation.comments, + textInputType: TextInputType.multiline, + alignLabelWithHint: true, + onChange: (text) { + requestDetailProvider.currentSelectedRequest.comments = text; + }, + onSaved: (text) { + requestDetailProvider.currentSelectedRequest.comments = text; + }, + ), + 16.height, + Consumer( + builder: (context, snapshot, _) => AppFilledButton( + label: context.translation.reject, + maxWidth: true, + buttonColor: Colors.white54, + textColor: AppColor.red50, + showBorder: true, + loading: snapshot.isLoading ?? false, + onPressed: () async { + _formKey.currentState!.save(); + // requestDetailProvider.serviceRequest.device = asset; + await snapshot.updateRequest(user: userProvider.user!, request: requestDetailProvider.currentSelectedRequest); + Navigator.pop(context, true); }, - onSaved: (text) { - requestDetailProvider.currentSelectedRequest.comments = text; - }, - ), - 16.height, - Consumer( - builder: (context, snapshot, _) => AppFilledButton( - label: context.translation.reject, - maxWidth: true, - buttonColor: Colors.white54, - textColor: AppColor.red50, - showBorder: true, - loading: snapshot.isLoading ?? false, - onPressed: () async { - _formKey.currentState.save(); - // requestDetailProvider.serviceRequest.device = asset; - await snapshot.updateRequest(user: userProvider.user, request: requestDetailProvider.currentSelectedRequest); - Navigator.pop(context, true); - }, - ), ), - 16.height, - ], - ), + ), + 16.height, + ], ), ), - ) - ], - ); - } - ); + ), + ) + ], + ); + }); } } diff --git a/lib/service_request_latest/views/components/bottom_sheets/service_request_bottomsheet.dart b/lib/service_request_latest/views/components/bottom_sheets/service_request_bottomsheet.dart index 5a17b604..b6712e5d 100644 --- a/lib/service_request_latest/views/components/bottom_sheets/service_request_bottomsheet.dart +++ b/lib/service_request_latest/views/components/bottom_sheets/service_request_bottomsheet.dart @@ -27,7 +27,7 @@ import '../../../../new_views/common_widgets/app_text_form_field.dart'; // class FixRemotlyBottomSheet extends StatelessWidget { // -// FixRemotlyBottomSheet({Key key,}) : super(key: key); +// FixRemotlyBottomSheet({Key? key,}) : super(key: key); // // final GlobalKey _formKey = GlobalKey(); // @@ -228,7 +228,7 @@ import '../../../../new_views/common_widgets/app_text_form_field.dart'; // } class ServiceRequestBottomSheet { - static Future fixRemotelyBottomSheet({@required BuildContext context}) { + static Future fixRemotelyBottomSheet({required BuildContext context}) { final GlobalKey _formKey = GlobalKey(); return showModalBottomSheet( context: context, @@ -432,7 +432,7 @@ class ServiceRequestBottomSheet { })); } - static Future initialVisitBottomSheet({@required BuildContext context}) { + static Future initialVisitBottomSheet({required BuildContext context}) { final GlobalKey _formKey = GlobalKey(); return showModalBottomSheet( context: context, @@ -601,7 +601,7 @@ class ServiceRequestBottomSheet { })); } - static Future rejectRequestBottomSheet({@required BuildContext context}) { + static Future rejectRequestBottomSheet({required BuildContext context}) { final GlobalKey _formKey = GlobalKey(); final userProvider = Provider.of(context, listen: false); return showModalBottomSheet( @@ -681,13 +681,13 @@ class ServiceRequestBottomSheet { })); } - static Future activityTypeBottomSheet({@required BuildContext context}) { + static Future activityTypeBottomSheet({required BuildContext context}) { final List> items = [ {'heading': context.translation.sparePartRequest, 'subHeading': context.translation.sparePartRequestDetail, 'icon': AppAsset.sparePartIcon}, {'heading': context.translation.maintenanceRequest, 'subHeading': context.translation.sparePartRequestDetail, 'icon': AppAsset.maintenanceIcon}, {'heading': context.translation.assetToBeRetired, 'subHeading': context.translation.sparePartRequestDetail, 'icon': AppAsset.retiredAssetIcon}, ]; - Widget listItem({@required BuildContext context, @required String icon, @required String heading, @required String subHeading, @required VoidCallback onTap}) { + Widget listItem({required BuildContext context, required String icon, required String heading, required String subHeading, required VoidCallback onTap}) { return Padding( padding: EdgeInsets.only(bottom: 8.toScreenHeight), child: Card( @@ -716,7 +716,7 @@ class ServiceRequestBottomSheet { ); } - void onItemTap({@required int index, @required ServiceRequest serviceRequest, @required BuildContext context}) { + void onItemTap({required int index, required ServiceRequest serviceRequest, required BuildContext context}) { print('on item tap i got index is $index'); switch (index) { case 0: @@ -792,7 +792,7 @@ class ServiceRequestBottomSheet { })); } - static Future actionBottomSheet({@required BuildContext context, @required String title, String button1Text, String button2Text, VoidCallback button1Tap, VoidCallback button2Tap}) { + static Future actionBottomSheet({required BuildContext context, required String title, String button1Text, String button2Text, VoidCallback button1Tap, VoidCallback button2Tap}) { final GlobalKey _formKey = GlobalKey(); final userProvider = Provider.of(context, listen: false); return showModalBottomSheet( diff --git a/lib/service_request_latest/views/components/history_log_view.dart b/lib/service_request_latest/views/components/history_log_view.dart index 0e92e25f..3067cf17 100644 --- a/lib/service_request_latest/views/components/history_log_view.dart +++ b/lib/service_request_latest/views/components/history_log_view.dart @@ -9,7 +9,7 @@ import 'package:test_sa/new_views/common_widgets/default_app_bar.dart'; import 'package:test_sa/views/widgets/requests/request_status.dart'; class HistoryLogView extends StatelessWidget { - const HistoryLogView({Key key}) : super(key: key); + const HistoryLogView({Key? key}) : super(key: key); @override Widget build(BuildContext context) { @@ -61,7 +61,7 @@ class HistoryLogView extends StatelessWidget { ); } - Widget historyLogCard({@required BuildContext context, @required HistoryLogModel historyLogModel}) { + Widget historyLogCard({required BuildContext context, required HistoryLogModel historyLogModel}) { return Column( crossAxisAlignment: CrossAxisAlignment.end, children: [ @@ -71,8 +71,8 @@ class HistoryLogView extends StatelessWidget { child: StatusLabel( radius: 4, label: historyLogModel.status, - textColor: AppColor.getRequestStatusTextColorByName(context, historyLogModel.status), - backgroundColor: AppColor.getRequestStatusColorByName(context, historyLogModel.status), + textColor: AppColor.getRequestStatusTextColorByName(context, historyLogModel.status!), + backgroundColor: AppColor.getRequestStatusColorByName(context, historyLogModel.status!), ), ) : 12.height, @@ -107,8 +107,8 @@ class HistoryLogView extends StatelessWidget { class HistoryLogModel { String message; DateTime date; - String status; - Color statusColor; + String? status; + Color? statusColor; - HistoryLogModel({@required this.message, @required this.date, this.status, this.statusColor}); + HistoryLogModel({required this.message, required this.date, this.status, this.statusColor}); } diff --git a/lib/service_request_latest/views/components/request_detail_view.dart b/lib/service_request_latest/views/components/request_detail_view.dart index 6f51e5a3..abc0f95f 100644 --- a/lib/service_request_latest/views/components/request_detail_view.dart +++ b/lib/service_request_latest/views/components/request_detail_view.dart @@ -1,4 +1,3 @@ -import 'package:another_flushbar/flushbar.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:test_sa/controllers/providers/api/all_requests_provider.dart'; @@ -16,11 +15,8 @@ import 'package:test_sa/new_views/app_style/app_color.dart'; import 'package:test_sa/new_views/common_widgets/app_filled_button.dart'; import 'package:test_sa/new_views/common_widgets/default_app_bar.dart'; import 'package:test_sa/service_request_latest/views/components/bottom_sheets/service_request_bottomsheet.dart'; -import 'package:test_sa/service_request_latest/views/components/bottom_sheets/reject_request_bottomsheet.dart'; import 'package:test_sa/service_request_latest/views/components/verify_otp_view.dart'; -import 'package:test_sa/utilities/general_utils.dart'; import 'package:test_sa/views/pages/user/requests/comments_bottom_sheet.dart'; -import 'package:test_sa/views/pages/user/requests/first_action_bottom_sheet.dart'; import 'package:test_sa/views/pages/user/requests/update_service_request_page.dart'; import 'package:test_sa/views/pages/user/requests/work_order/work_orders_list_page.dart'; import 'package:test_sa/views/widgets/images/files_list.dart'; @@ -28,14 +24,12 @@ import 'package:test_sa/views/widgets/loaders/app_loading.dart'; import 'package:test_sa/views/widgets/requests/request_status.dart'; import 'package:test_sa/views/widgets/sound/sound_player.dart'; -import 'bottom_sheets/initial_visit_bottomsheet.dart'; - class RequestDetailView extends StatefulWidget { static const String id = "/call-details"; ServiceRequest serviceRequest; - bool fromTabView=false; + bool fromTabView = false; - RequestDetailView({Key key, this.serviceRequest,this.fromTabView=false}) : super(key: key); + RequestDetailView({Key? key, required this.serviceRequest, this.fromTabView = false}) : super(key: key); @override State createState() => _RequestDetailViewState(); @@ -48,7 +42,7 @@ class _RequestDetailViewState extends State { getServiceRequest(requestId: widget.serviceRequest.id); } - void getServiceRequest({@required dynamic requestId}) { + void getServiceRequest({required dynamic requestId}) { // setState(() {}); WidgetsFlutterBinding.ensureInitialized().addPostFrameCallback((timeStamp) async { Provider.of(context, listen: false).reset(); @@ -61,141 +55,145 @@ class _RequestDetailViewState extends State { @override Widget build(BuildContext context) { UserProvider _userProvider = Provider.of(context, listen: false); - return !widget.fromTabView? Scaffold( - appBar:DefaultAppBar(title: context.translation.serviceDetails), - body: Padding( - padding: EdgeInsets.only(top: 12.toScreenHeight), - child: Consumer(builder: (context, serviceRequestsProvider, child) { - return requestDetailCard(serviceRequestsProvider: serviceRequestsProvider,userProvider: _userProvider); - }), - ), - ):Consumer(builder: (context, serviceRequestsProvider, child) { - return requestDetailCard(serviceRequestsProvider: serviceRequestsProvider,userProvider: _userProvider); - }); + return !widget.fromTabView + ? Scaffold( + appBar: DefaultAppBar(title: context.translation.serviceDetails), + body: Padding( + padding: EdgeInsets.only(top: 12.toScreenHeight), + child: Consumer(builder: (context, serviceRequestsProvider, child) { + return requestDetailCard(serviceRequestsProvider: serviceRequestsProvider, userProvider: _userProvider); + }), + ), + ) + : Consumer(builder: (context, serviceRequestsProvider, child) { + return requestDetailCard(serviceRequestsProvider: serviceRequestsProvider, userProvider: _userProvider); + }); } - Widget requestDetailCard({ ServiceRequestsProvider serviceRequestsProvider,UserProvider userProvider}){ + + Widget requestDetailCard({required ServiceRequestsProvider serviceRequestsProvider, required UserProvider userProvider}) { return SafeArea( child: serviceRequestsProvider.isDetialLoading ? const ALoading().center : serviceRequestsProvider.currentSelectedRequest == null - ? Text( - context.translation.noDataFound, - style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20), - ).center - : Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SingleChildScrollView( - padding: EdgeInsets.symmetric(horizontal: 16.toScreenWidth), - child: informationCard(serviceRequestsProvider.currentSelectedRequest,userProvider), - ).expanded, - Center( - child: InkWell( - onTap: () async { - try{ - //use a common list - AllRequestsProvider allRequestProvider = Provider.of(context, listen: false); - int index = allRequestProvider.requestDetailList.requestsDetails.indexWhere((element) => element.id.toString() == serviceRequestsProvider.currentSelectedRequest.id); - if (index != -1 && index != allRequestProvider.requestDetailList.requestsDetails.length) { - getServiceRequest(requestId: allRequestProvider.requestDetailList.requestsDetails[index + 1].id.toString()); - } - }catch(e){ - print(e); - } - }, - child: Text( - context.translation.skipForLater, - style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20, decoration: TextDecoration.underline, fontSize: 16), - ), - ), - ), - 20.height, - if (userProvider.user.type == UsersTypes.engineer || - (serviceRequestsProvider.currentSelectedRequest.statusValue == 5 || serviceRequestsProvider.currentSelectedRequest.statusValue == 3)) - (serviceRequestsProvider.currentSelectedRequest?.firstAction == null - ? Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - mainAxisSize: MainAxisSize.min, - children: [ - AppFilledButton( - label: context.translation.reject, - maxWidth: true, - buttonColor: Colors.white54, - textColor: AppColor.red50, - showBorder: true, - onPressed: () async { - ServiceRequestBottomSheet.rejectRequestBottomSheet(context: context); - // bool shouldReloadData = (await showModalBottomSheet( - // context: context, - // useSafeArea: true, - // isScrollControlled: true, - // backgroundColor: Colors.transparent, - // builder: (context) => RejectRequestBottomSheet(), - // )) as bool; - // if (shouldReloadData ?? false) { - // getServiceRequest(); - // } - }, - ).expanded, - const SizedBox( - width: 20, - ), - AppFilledButton( - label: context.translation.accept, - maxWidth: true, - buttonColor: AppColor.green70, - onPressed: () async { - // GeneralUtils.showFlushBar(context: context); - Navigator.of(context).push(MaterialPageRoute(builder: (_) => const VerifyOtpView())); + ? Text( + context.translation.noDataFound, + style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20), + ).center + : Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SingleChildScrollView( + padding: EdgeInsets.symmetric(horizontal: 16.toScreenWidth), + child: informationCard(serviceRequestsProvider.currentSelectedRequest, userProvider), + ).expanded, + Center( + child: InkWell( + onTap: () async { + try { + //use a common list + AllRequestsProvider allRequestProvider = Provider.of(context, listen: false); + int index = allRequestProvider.requestDetailList!.requestsDetails!.indexWhere((element) => element.id.toString() == serviceRequestsProvider.currentSelectedRequest.id); + if (index != -1 && index != allRequestProvider.requestDetailList!.requestsDetails!.length) { + getServiceRequest(requestId: allRequestProvider.requestDetailList!.requestsDetails![index + 1].id.toString()); + } + } catch (e) { + print(e); + } + }, + child: Text( + context.translation.skipForLater, + style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20, decoration: TextDecoration.underline, fontSize: 16), + ), + ), + ), + 20.height, + if (userProvider.user!.type == UsersTypes.engineer || + (serviceRequestsProvider.currentSelectedRequest.statusValue == 5 || serviceRequestsProvider.currentSelectedRequest.statusValue == 3)) + (serviceRequestsProvider.currentSelectedRequest?.firstAction == null + ? Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisSize: MainAxisSize.min, + children: [ + AppFilledButton( + label: context.translation.reject, + maxWidth: true, + buttonColor: Colors.white54, + textColor: AppColor.red50, + showBorder: true, + onPressed: () async { + ServiceRequestBottomSheet.rejectRequestBottomSheet(context: context); + // bool shouldReloadData = (await showModalBottomSheet( + // context: context, + // useSafeArea: true, + // isScrollControlled: true, + // backgroundColor: Colors.transparent, + // builder: (context) => RejectRequestBottomSheet(), + // )) as bool; + // if (shouldReloadData ?? false) { + // getServiceRequest(); + // } + }, + ).expanded, + const SizedBox( + width: 20, + ), + AppFilledButton( + label: context.translation.accept, + maxWidth: true, + buttonColor: AppColor.green70, + onPressed: () async { + // GeneralUtils.showFlushBar(context: context); + Navigator.of(context).push(MaterialPageRoute(builder: (_) => const VerifyOtpView())); - // ServiceRequestBottomSheet.fixRemotelyBottomSheet(context: context); - // bool shouldReloadData = (await showModalBottomSheet( - // context: context, - // useSafeArea: true, - // isScrollControlled: true, - // backgroundColor: Colors.transparent, - // builder: (context) => InitialVisitBottomSheet(), - // )) as bool; - // if (shouldReloadData ?? false) { - // getServiceRequest(); - // } - }, - ).expanded, - ], - ) - // ? AppFilledButton( - // label: context.translation.firstAction, - // maxWidth: true, - // onPressed: () async { - // bool shouldReloadData = (await showModalBottomSheet( - // context: context, - // useSafeArea: true, - // isScrollControlled: true, - // backgroundColor: Colors.transparent, - // builder: (context) => FirstActionBottomSheet(request: serviceRequestsProvider.serviceRequest), - // )) as bool; - // if (shouldReloadData ?? false) { - // getServiceRequest(); - // } - // }, - // ) - : AppFilledButton( - label: context.translation.viewWorkOrder, - maxWidth: true, - onPressed: () { - Navigator.push( - context, - MaterialPageRoute(builder: (context) => WorkOrderListPage(serviceRequest: serviceRequestsProvider.currentSelectedRequest)), - ); - // Navigator.of(context).pushNamed(WorkOrderListPage.id, arguments: serviceRequest); - }, - )) - .paddingOnly(start: 16, end: 16, bottom: 24), - ], - ), + // ServiceRequestBottomSheet.fixRemotelyBottomSheet(context: context); + // bool shouldReloadData = (await showModalBottomSheet( + // context: context, + // useSafeArea: true, + // isScrollControlled: true, + // backgroundColor: Colors.transparent, + // builder: (context) => InitialVisitBottomSheet(), + // )) as bool; + // if (shouldReloadData ?? false) { + // getServiceRequest(); + // } + }, + ).expanded, + ], + ) + // ? AppFilledButton( + // label: context.translation.firstAction, + // maxWidth: true, + // onPressed: () async { + // bool shouldReloadData = (await showModalBottomSheet( + // context: context, + // useSafeArea: true, + // isScrollControlled: true, + // backgroundColor: Colors.transparent, + // builder: (context) => FirstActionBottomSheet(request: serviceRequestsProvider.serviceRequest), + // )) as bool; + // if (shouldReloadData ?? false) { + // getServiceRequest(); + // } + // }, + // ) + : AppFilledButton( + label: context.translation.viewWorkOrder, + maxWidth: true, + onPressed: () { + Navigator.push( + context, + MaterialPageRoute(builder: (context) => WorkOrderListPage(serviceRequest: serviceRequestsProvider.currentSelectedRequest)), + ); + // Navigator.of(context).pushNamed(WorkOrderListPage.id, arguments: serviceRequest); + }, + )) + .paddingOnly(start: 16, end: 16, bottom: 24), + ], + ), ); } - Widget informationCard(ServiceRequest serviceRequest,UserProvider userProvider) { + + Widget informationCard(ServiceRequest serviceRequest, UserProvider userProvider) { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -213,30 +211,30 @@ class _RequestDetailViewState extends State { mainAxisSize: MainAxisSize.min, children: [ StatusLabel( - label: serviceRequest.priority.name, - id: serviceRequest.priority.id, + label: serviceRequest.priority?.name, + id: serviceRequest.priority!.id!, radius: 4, - textColor: AppColor.getPriorityStatusTextColor(context, serviceRequest.priority.id), - backgroundColor: AppColor.getPriorityStatusColor(context, serviceRequest.priority.id), + textColor: AppColor.getPriorityStatusTextColor(context, serviceRequest.priority!.id!), + backgroundColor: AppColor.getPriorityStatusColor(context, serviceRequest.priority!.id!), ), 8.width, StatusLabel( radius: 4, - label: serviceRequest.statusLabel, - textColor: AppColor.getRequestStatusTextColor(context, serviceRequest.statusValue), - backgroundColor: AppColor.getRequestStatusColor(context, serviceRequest.statusValue), + label: serviceRequest.statusLabel!, + textColor: AppColor.getRequestStatusTextColor(context, serviceRequest.statusValue!), + backgroundColor: AppColor.getRequestStatusColor(context, serviceRequest.statusValue!), ), 1.width.expanded, Column( crossAxisAlignment: CrossAxisAlignment.end, children: [ - if (userProvider.user.type == UsersTypes.normal_user) + if (userProvider.user!.type == UsersTypes.normal_user) context.translation.code.toSvgAsset(width: 48).onPress(() { Navigator.push(context, MaterialPageRoute(builder: (context) => UpdateServiceRequestPage(serviceRequest: serviceRequest))); }), - if (userProvider.user.type == UsersTypes.engineer) 16.height, + if (userProvider.user!.type == UsersTypes.engineer) 16.height, Text( - serviceRequest.date.toServiceRequestCardFormat, + serviceRequest.date!.toServiceRequestCardFormat, textAlign: TextAlign.end, style: AppTextStyles.tinyFont.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50), ), @@ -261,31 +259,31 @@ class _RequestDetailViewState extends State { style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20), ), Text( - '${context.translation.manufacture}: ${serviceRequest.device.modelDefinition.manufacturerName?.cleanupWhitespace?.capitalizeFirstOfEach}', + '${context.translation.manufacture}: ${serviceRequest.device!.modelDefinition?.manufacturerName?.cleanupWhitespace?.capitalizeFirstOfEach}', style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20), ), Text( - '${context.translation.model}: ${serviceRequest.device.modelDefinition.modelName?.cleanupWhitespace?.capitalizeFirstOfEach}', + '${context.translation.model}: ${serviceRequest.device!.modelDefinition?.modelName?.cleanupWhitespace?.capitalizeFirstOfEach}', style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20), ), Text( - '${context.translation.site}: ${serviceRequest.device.site?.custName?.cleanupWhitespace?.capitalizeFirstOfEach}', + '${context.translation.site}: ${serviceRequest.device!.site?.custName?.cleanupWhitespace?.capitalizeFirstOfEach}', style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20), ), Text( - '${context.translation.building}: ${serviceRequest.device.building?.name?.cleanupWhitespace?.capitalizeFirstOfEach}', + '${context.translation.building}: ${serviceRequest.device!.building?.name?.cleanupWhitespace?.capitalizeFirstOfEach}', style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20), ), Text( - '${context.translation.floor}: ${serviceRequest.device.floor?.name?.cleanupWhitespace?.capitalizeFirstOfEach ?? ""}', + '${context.translation.floor}: ${serviceRequest.device!.floor?.name?.cleanupWhitespace?.capitalizeFirstOfEach ?? ""}', style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20), ), Text( - '${context.translation.department}: ${serviceRequest.device.department?.departmentName?.cleanupWhitespace?.capitalizeFirstOfEach}', + '${context.translation.department}: ${serviceRequest.device!.department?.departmentName?.cleanupWhitespace?.capitalizeFirstOfEach}', style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20), ), Text( - '${context.translation.room}: ${(serviceRequest.device.room?.name ?? "").cleanupWhitespace?.capitalizeFirstOfEach}', + '${context.translation.room}: ${(serviceRequest.device!.room?.name ?? "").cleanupWhitespace?.capitalizeFirstOfEach}', style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20), ), ], @@ -302,7 +300,7 @@ class _RequestDetailViewState extends State { ), 8.height, Text( - '${context.translation.requestType}: ${serviceRequest.type.name}', + '${context.translation.requestType}: ${serviceRequest.type!.name}', style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20), ), Text( @@ -319,69 +317,69 @@ class _RequestDetailViewState extends State { const Divider().defaultStyle(context), 8.height, Text( - serviceRequest.callComments, + serviceRequest.callComments!, style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20), ), ], - if (serviceRequest.devicePhotos.isNotEmpty) ...[ + if (serviceRequest.devicePhotos?.isNotEmpty ?? false) ...[ 8.height, const Divider().defaultStyle(context), - FilesList(images: serviceRequest.devicePhotos), + FilesList(images: serviceRequest.devicePhotos!), ], if (serviceRequest.audio?.isNotEmpty ?? false) ...[ const Divider().defaultStyle(context), 16.height, - ASoundPlayer(audio: serviceRequest.audio), + ASoundPlayer(audio: serviceRequest.audio!), 8.height, ], ], ).paddingOnly(start: 16, end: 16, top: 16, bottom: 8), - (userProvider.user.type == UsersTypes.normal_user - ? Container( - height: 50, - padding: const EdgeInsets.only(left: 16, right: 16), - alignment: Alignment.center, - width: double.infinity, - decoration: ShapeDecoration( - color: context.isDark ? AppColor.neutral50 : AppColor.neutral30, - shape: const RoundedRectangleBorder( - borderRadius: BorderRadius.only( - bottomLeft: Radius.circular(20), - bottomRight: Radius.circular(20), - ), - ), - ), - child: Row( - children: [ - Text( - '${context.translation.commentHere}...', - style: AppTextStyles.heading6.copyWith( - color: (context.isDark ? AppColor.neutral30 : AppColor.neutral50).withOpacity(.6), - ), - ).expanded, - "comment_send".toSvgAsset(width: 24, color: context.isDark ? AppColor.primary50 : AppColor.primary70), - ], - ), - ) - : Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - const Divider().defaultStyle(context), - 16.height, - Row( - mainAxisSize: MainAxisSize.min, - children: [ - Text( - context.translation.viewComments, - style: AppTextStyles.bodyText.copyWith(color: AppColor.blueStatus(context)), - ), - 4.width, - Icon(Icons.arrow_forward, color: AppColor.blueStatus(context), size: 14) - ], - ), - ], - ).paddingOnly(bottom: 16, start: 16, end: 16)) + (userProvider.user!.type == UsersTypes.normal_user + ? Container( + height: 50, + padding: const EdgeInsets.only(left: 16, right: 16), + alignment: Alignment.center, + width: double.infinity, + decoration: ShapeDecoration( + color: context.isDark ? AppColor.neutral50 : AppColor.neutral30, + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(20), + bottomRight: Radius.circular(20), + ), + ), + ), + child: Row( + children: [ + Text( + '${context.translation.commentHere}...', + style: AppTextStyles.heading6.copyWith( + color: (context.isDark ? AppColor.neutral30 : AppColor.neutral50).withOpacity(.6), + ), + ).expanded, + "comment_send".toSvgAsset(width: 24, color: context.isDark ? AppColor.primary50 : AppColor.primary70), + ], + ), + ) + : Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Divider().defaultStyle(context), + 16.height, + Row( + mainAxisSize: MainAxisSize.min, + children: [ + Text( + context.translation.viewComments, + style: AppTextStyles.bodyText.copyWith(color: AppColor.blueStatus(context)), + ), + 4.width, + Icon(Icons.arrow_forward, color: AppColor.blueStatus(context), size: 14) + ], + ), + ], + ).paddingOnly(bottom: 16, start: 16, end: 16)) .onPress(() { showModalBottomSheet( context: context, @@ -389,7 +387,7 @@ class _RequestDetailViewState extends State { isScrollControlled: true, useRootNavigator: true, backgroundColor: Colors.transparent, - builder: (context) => CommentsBottomSheet(requestId: serviceRequest.id), + builder: (context) => CommentsBottomSheet(requestId: serviceRequest.id!), ); }), ], diff --git a/lib/service_request_latest/views/components/scan_qr_view.dart b/lib/service_request_latest/views/components/scan_qr_view.dart index 23740b79..08345e42 100644 --- a/lib/service_request_latest/views/components/scan_qr_view.dart +++ b/lib/service_request_latest/views/components/scan_qr_view.dart @@ -8,15 +8,15 @@ import 'package:test_sa/new_views/common_widgets/default_app_bar.dart'; class ScanQrView extends StatefulWidget { - const ScanQrView({Key key}) : super(key: key); + const ScanQrView({Key? key}) : super(key: key); @override _ScanQrViewState createState() => _ScanQrViewState(); } class _ScanQrViewState extends State { - Barcode result; - QRViewController _controller; + // Barcode result; + QRViewController? _controller; bool _scanDone = false; final GlobalKey qrKey = GlobalKey(debugLabel: 'QR_scanner'); diff --git a/lib/service_request_latest/views/components/spare_part_request.dart b/lib/service_request_latest/views/components/spare_part_request.dart index 68077dec..48517776 100644 --- a/lib/service_request_latest/views/components/spare_part_request.dart +++ b/lib/service_request_latest/views/components/spare_part_request.dart @@ -1,9 +1,7 @@ -import 'dart:convert'; import 'dart:io'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; -import 'package:test_sa/attachment.dart'; import 'package:test_sa/controllers/providers/api/parts_provider.dart'; import 'package:test_sa/controllers/providers/api/service_requests_provider.dart'; import 'package:test_sa/controllers/providers/api/user_provider.dart'; @@ -19,11 +17,10 @@ import 'package:test_sa/new_views/common_widgets/app_filled_button.dart'; import 'package:test_sa/new_views/common_widgets/single_item_drop_down_menu.dart'; import 'package:test_sa/providers/loading_list_notifier.dart'; import 'package:test_sa/providers/work_order/reason_provider.dart'; -import 'package:test_sa/service_request_latest/views/components/bottom_sheets/action_bottomsheet.dart'; import 'package:test_sa/service_request_latest/views/components/bottom_sheets/service_request_bottomsheet.dart'; -import 'package:test_sa/views/pages/user/requests/work_order/part_no_button.dart'; import 'package:test_sa/views/widgets/images/multi_image_picker.dart'; import 'package:test_sa/views/widgets/loaders/loading_manager.dart'; + import '../../../../../controllers/providers/api/status_drop_down/report/service_report_last_calls_provider.dart'; import '../../../../../controllers/providers/api/status_drop_down/report/service_types_provider.dart'; import '../../../../../models/lookup.dart'; @@ -35,19 +32,19 @@ import '../../../controllers/validator/validator.dart'; class SparePartRequest extends StatefulWidget { static const String id = "/spare-part-request"; - const SparePartRequest({Key key}) : super(key: key); + const SparePartRequest({Key? key}) : super(key: key); @override _SparePartRequestState createState() => _SparePartRequestState(); } class _SparePartRequestState extends State with TickerProviderStateMixin { - UserProvider _userProvider; - SettingProvider _settingProvider; - ServiceRequestsProvider _serviceRequestsProvider; - ServiceStatusProvider _assetTypeProvider; - PartsProvider _partsProvider; - ServiceReport _serviceReport; + late UserProvider _userProvider; + late SettingProvider _settingProvider; + late ServiceRequestsProvider _serviceRequestsProvider; + late ServiceStatusProvider _assetTypeProvider; + late PartsProvider _partsProvider; + late ServiceReport _serviceReport; bool _isLoading = false; List _spareParts = []; @@ -77,7 +74,7 @@ class _SparePartRequestState extends State with TickerProvider // _isLoading = true; } - Asset loanAvailabilityAsset; + //Asset loanAvailabilityAsset; @override void dispose() { @@ -91,8 +88,8 @@ class _SparePartRequestState extends State with TickerProvider _isLoading = true; setState(() {}); ServiceRequestsProvider serviceRequestsProvider = Provider.of(context, listen: false); - _serviceReport.callRequest = await _serviceRequestsProvider.getCallRequestForWorkOrder(callId: serviceRequestsProvider.currentSelectedRequest.id); - await _assetTypeProvider.getTypes(user: _userProvider.user, host: _settingProvider.host); + _serviceReport.callRequest = await _serviceRequestsProvider.getCallRequestForWorkOrder(callId: serviceRequestsProvider.currentSelectedRequest.id!); + await _assetTypeProvider.getTypes(); _serviceReport.assignedEmployee = _serviceReport.callRequest?.assignedEmployee; _serviceReport.equipmentStatus = _serviceReport.callRequest?.defectType; _serviceReport.serviceType = Lookup(id: 65, name: "Interval", value: 1); // default value in service type as in web @@ -113,7 +110,7 @@ class _SparePartRequestState extends State with TickerProvider } _serviceReport.assetType = _assetTypeProvider.statuses?.firstWhere( (element) => element.value == _serviceReport.callRequest?.assetType, - orElse: () => null, + orElse: null, ); return Scaffold( @@ -191,7 +188,7 @@ class _SparePartRequestState extends State with TickerProvider ), 15.height, AppTextFormField( - initialValue: _serviceReport?.comment, + initialValue: _serviceReport.comment ?? "", backgroundColor: context.isDark ? AppColor.neutral20 : AppColor.neutral90, labelText: context.translation.description, alignLabelWithHint: true, diff --git a/lib/service_request_latest/views/components/verify_arrival_view.dart b/lib/service_request_latest/views/components/verify_arrival_view.dart index 5aa9d97a..da3059d1 100644 --- a/lib/service_request_latest/views/components/verify_arrival_view.dart +++ b/lib/service_request_latest/views/components/verify_arrival_view.dart @@ -6,16 +6,14 @@ import 'package:test_sa/controllers/providers/api/service_requests_provider.dart import 'package:test_sa/extensions/context_extension.dart'; import 'package:test_sa/extensions/int_extensions.dart'; import 'package:test_sa/extensions/text_extensions.dart'; -import 'package:test_sa/extensions/widget_extensions.dart'; import 'package:test_sa/models/service_request/service_request.dart'; import 'package:test_sa/new_views/common_widgets/default_app_bar.dart'; import 'package:test_sa/service_request_latest/views/components/scan_qr_view.dart'; -import 'package:test_sa/views/widgets/qr/scan_qr.dart'; import 'activities_list_view.dart'; class VerifyArrivalView extends StatelessWidget { - VerifyArrivalView({Key key}) : super(key: key); + VerifyArrivalView({Key? key}) : super(key: key); @override Widget build(BuildContext context) { @@ -31,19 +29,18 @@ class VerifyArrivalView extends StatelessWidget { body: Consumer(builder: (context, serviceRequestsProvider, child) { return SafeArea( child: ListView.builder( - padding: EdgeInsets.symmetric(vertical: 12.toScreenHeight), + padding: EdgeInsets.symmetric(vertical: 12.toScreenHeight), // padding: EdgeInsets.zero, itemCount: items.length, itemBuilder: (context, index) { final item = items[index]; return listItem( - icon: item['icon'], - heading: item['heading'], - subHeading: item['subHeading'], - context: context, + icon: item['icon']!, + heading: item['heading']!, + subHeading: item['subHeading']!, + //context: context, onTap: () { - - onItemTap(serviceRequest: serviceRequestsProvider.currentSelectedRequest, index: index,context: context); + onItemTap(serviceRequest: serviceRequestsProvider.currentSelectedRequest, index: index, context: context); }); }, ), @@ -52,61 +49,56 @@ class VerifyArrivalView extends StatelessWidget { ); } - Widget listItem({@required BuildContext context, @required String icon, @required String heading, @required String subHeading, @required VoidCallback onTap}) { + Widget listItem({required String icon, required String heading, required String subHeading, required VoidCallback onTap}) { return Padding( - padding: EdgeInsets.only(left: 16.toScreenWidth,right: 16.toScreenWidth,bottom: 12.toScreenHeight), - + padding: EdgeInsets.only(left: 16.toScreenWidth, right: 16.toScreenWidth, bottom: 12.toScreenHeight), child: Card( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(14), // Circular border radius ), color: Colors.white, - child: - ListTile( + child: ListTile( minVerticalPadding: 12, horizontalTitleGap: 10, onTap: onTap, // contentPadding: const EdgeInsets.all(12), leading: SvgPicture.asset(icon), - title: Text( - heading, - style: AppTextStyles.heading5, - ), - subtitle: Text( - subHeading, - style: AppTextStyles.bodyText, - ), + title: Text(heading, style: AppTextStyles.heading5), + subtitle: Text(subHeading, style: AppTextStyles.bodyText), ), ), ); } - void onItemTap({@required int index, @required ServiceRequest serviceRequest,@required BuildContext context}) { + void onItemTap({required int index, required ServiceRequest serviceRequest, required BuildContext context}) { print('on item tap i got index is $index'); - switch(index){ + switch (index) { case 0: Navigator.push( context, - MaterialPageRoute(builder: (context) => const ScanQrView()), + MaterialPageRoute(builder: (context) => const ScanQrView()), ); - break;case 1: - //push to specific screen... + break; + case 1: + //push to specific screen... Navigator.push( context, - MaterialPageRoute(builder: (context) => ActivitiesListView()), + MaterialPageRoute(builder: (context) => ActivitiesListView()), ); - break;case 2: - //push to specific screen... - // Navigator.push( - // context, - // MaterialPageRoute(builder: (context) => const ScanQrView()), - // ); - break;case 2: - //push to specific screen... - // Navigator.push( - // context, - // MaterialPageRoute(builder: (context) => const ScanQrView()), - // ); + break; + case 2: + //push to specific screen... + // Navigator.push( + // context, + // MaterialPageRoute(builder: (context) => const ScanQrView()), + // ); + break; + case 2: + //push to specific screen... + // Navigator.push( + // context, + // MaterialPageRoute(builder: (context) => const ScanQrView()), + // ); break; } // ScanQr diff --git a/lib/service_request_latest/views/components/verify_otp_view.dart b/lib/service_request_latest/views/components/verify_otp_view.dart index fff00916..9e0e6981 100644 --- a/lib/service_request_latest/views/components/verify_otp_view.dart +++ b/lib/service_request_latest/views/components/verify_otp_view.dart @@ -10,7 +10,7 @@ import 'package:test_sa/new_views/common_widgets/default_app_bar.dart'; import 'package:test_sa/views/widgets/timer/app_timer.dart'; class VerifyOtpView extends StatelessWidget { - const VerifyOtpView({Key key}) : super(key: key); + const VerifyOtpView({Key? key}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/service_request_latest/views/request_detail_main_view.dart b/lib/service_request_latest/views/request_detail_main_view.dart index 1ab3c9d9..3feab526 100644 --- a/lib/service_request_latest/views/request_detail_main_view.dart +++ b/lib/service_request_latest/views/request_detail_main_view.dart @@ -12,7 +12,7 @@ import 'components/request_detail_view.dart'; class RequestDetailMain extends StatelessWidget { final int requestId; - const RequestDetailMain({Key key,this.requestId}) : super(key: key); + const RequestDetailMain({Key? key,required this.requestId}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/utilities/general_utils.dart b/lib/utilities/general_utils.dart index 43633bc4..d5548eae 100644 --- a/lib/utilities/general_utils.dart +++ b/lib/utilities/general_utils.dart @@ -25,7 +25,7 @@ class GeneralUtils{ return Duration.zero; // Return zero duration in case of an error } } - static Widget showFlushBar({@required BuildContext context,String title,String message,double duration}){ + static Widget showFlushBar({required BuildContext context,String title,String message,double duration}){ return Flushbar( flushbarPosition: FlushbarPosition.TOP, backgroundColor: AppColor.green70, diff --git a/lib/utilities/request_utils.dart b/lib/utilities/request_utils.dart index 81c441cc..3fa84eb1 100644 --- a/lib/utilities/request_utils.dart +++ b/lib/utilities/request_utils.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import 'package:test_sa/models/enums/user_types.dart'; class RequestUtils{ - static List> getTabs({@required UsersTypes userType,@required BuildContext context}) { + static List> getTabs({required UsersTypes userType,required BuildContext context}) { List> tabs = []; if(userType==UsersTypes.engineer){ tabs.add({'label':'In Progress','status':2}); diff --git a/lib/views/pages/device_transfer/asset_filter_screen.dart b/lib/views/pages/device_transfer/asset_filter_screen.dart index 39c75fc8..422b71c5 100644 --- a/lib/views/pages/device_transfer/asset_filter_screen.dart +++ b/lib/views/pages/device_transfer/asset_filter_screen.dart @@ -24,7 +24,7 @@ class AssetFilterScreen extends StatefulWidget { static const String id = "asset_filter_screen"; final AssetSearch data; - const AssetFilterScreen({Key key, this.data}) : super(key: key); + const AssetFilterScreen({Key? key, this.data}) : super(key: key); @override State createState() => _AssetFilterScreenState(); diff --git a/lib/views/pages/device_transfer/asset_search_screen.dart b/lib/views/pages/device_transfer/asset_search_screen.dart index 98fe81cb..007895b7 100644 --- a/lib/views/pages/device_transfer/asset_search_screen.dart +++ b/lib/views/pages/device_transfer/asset_search_screen.dart @@ -16,7 +16,7 @@ class AssetSearchScreen extends StatefulWidget { static const String id = "asset_search_screen"; final AssetSearch data; - const AssetSearchScreen({Key key, this.data}) : super(key: key); + const AssetSearchScreen({Key? key, this.data}) : super(key: key); @override State createState() => _AssetSearchScreenState(); diff --git a/lib/views/pages/device_transfer/device_transfer_details.dart b/lib/views/pages/device_transfer/device_transfer_details.dart index 9b26a152..0a0313d9 100644 --- a/lib/views/pages/device_transfer/device_transfer_details.dart +++ b/lib/views/pages/device_transfer/device_transfer_details.dart @@ -20,7 +20,7 @@ import '../../widgets/requests/request_status.dart'; class DeviceTransferDetails extends StatefulWidget { final AssetTransfer model; - const DeviceTransferDetails({Key key, this.model}) : super(key: key); + const DeviceTransferDetails({Key? key, this.model}) : super(key: key); @override State createState() => _DeviceTransferDetailsState(); @@ -176,7 +176,7 @@ class _DeviceTransferDetailsState extends State { return text.bodyText(context); } - _buildCard({@required String site, @required String unit, @required String comment, @required bool isSender, StatusLabel statusLabel}) { + _buildCard({required String site, required String unit, required String comment, required bool isSender, StatusLabel statusLabel}) { bool isCurrentEngineerEligibleForEdit = isSender ? _model?.senderAssignedEmployeeId == _userProvider.user?.userID : _model?.receiverAssignedEmployeeId == _userProvider.user?.userID; bool isCurrentRequestClosed = isSender diff --git a/lib/views/pages/device_transfer/request_device_transfer.dart b/lib/views/pages/device_transfer/request_device_transfer.dart index 543fe640..bc1412af 100644 --- a/lib/views/pages/device_transfer/request_device_transfer.dart +++ b/lib/views/pages/device_transfer/request_device_transfer.dart @@ -29,7 +29,7 @@ import '../../widgets/equipment/pick_asset.dart'; class RequestDeviceTransfer extends StatefulWidget { static const String id = "/request-device-transfer"; - const RequestDeviceTransfer({Key key}) : super(key: key); + const RequestDeviceTransfer({Key? key}) : super(key: key); @override State createState() => _RequestDeviceTransferState(); diff --git a/lib/views/pages/device_transfer/search_asset_page.dart b/lib/views/pages/device_transfer/search_asset_page.dart index 53425d5b..9491f4a9 100644 --- a/lib/views/pages/device_transfer/search_asset_page.dart +++ b/lib/views/pages/device_transfer/search_asset_page.dart @@ -21,7 +21,7 @@ class SearchAssetPage extends StatefulWidget { /// add on route static const String id = "asset_search_page"; - const SearchAssetPage({Key key}) : super(key: key); + const SearchAssetPage({Key? key}) : super(key: key); @override State createState() => _SearchAssetPageState(); diff --git a/lib/views/pages/device_transfer/track_device_transfer.dart b/lib/views/pages/device_transfer/track_device_transfer.dart index 373a67d2..e3d7f355 100644 --- a/lib/views/pages/device_transfer/track_device_transfer.dart +++ b/lib/views/pages/device_transfer/track_device_transfer.dart @@ -12,7 +12,7 @@ import '../../../new_views/common_widgets/default_app_bar.dart'; class TrackDeviceTransferPage extends StatefulWidget { static const String id = "/track-device-transfer"; - const TrackDeviceTransferPage({Key key}) : super(key: key); + const TrackDeviceTransferPage({Key? key}) : super(key: key); @override State createState() => _TrackDeviceTransferPageState(); diff --git a/lib/views/pages/device_transfer/update_device_transfer.dart b/lib/views/pages/device_transfer/update_device_transfer.dart index 553d33d7..7902acfc 100644 --- a/lib/views/pages/device_transfer/update_device_transfer.dart +++ b/lib/views/pages/device_transfer/update_device_transfer.dart @@ -38,7 +38,7 @@ class UpdateDeviceTransfer extends StatefulWidget { final AssetTransfer model; final bool isSender; - const UpdateDeviceTransfer({Key key, this.model, this.isSender}) : super(key: key); + const UpdateDeviceTransfer({Key? key, this.model, this.isSender}) : super(key: key); @override State createState() => _UpdateDeviceTransferState(); diff --git a/lib/views/pages/splash_screen.dart b/lib/views/pages/splash_screen.dart index bc7bac95..046e4ebd 100644 --- a/lib/views/pages/splash_screen.dart +++ b/lib/views/pages/splash_screen.dart @@ -14,7 +14,7 @@ // class SplashScreen extends StatefulWidget { // static const String id = '/splash'; // -// const SplashScreen({Key key}) : super(key: key); +// const SplashScreen({Key? key}) : super(key: key); // // @override // State createState() => _SplashScreenState(); diff --git a/lib/views/pages/sub_workorder/auto_generated_vendor_name.dart b/lib/views/pages/sub_workorder/auto_generated_vendor_name.dart index 8e075094..5401ebc6 100644 --- a/lib/views/pages/sub_workorder/auto_generated_vendor_name.dart +++ b/lib/views/pages/sub_workorder/auto_generated_vendor_name.dart @@ -11,7 +11,7 @@ // final String initialValue; // final Function(SupplierDetails) onSearch; // -// const AutoGeneratedVendorName({Key key, this.initialValue, this.onSearch}) : super(key: key); +// const AutoGeneratedVendorName({Key? key, this.initialValue, this.onSearch}) : super(key: key); // // @override // State createState() => _AutoGeneratedVendorNameState(); diff --git a/lib/views/pages/sub_workorder/create_sub_workorder_page.dart b/lib/views/pages/sub_workorder/create_sub_workorder_page.dart index 2e1ccef3..14b5bb9e 100644 --- a/lib/views/pages/sub_workorder/create_sub_workorder_page.dart +++ b/lib/views/pages/sub_workorder/create_sub_workorder_page.dart @@ -59,7 +59,7 @@ class CreateSubWorkOrderPage extends StatefulWidget { static const id = "/CreateSubWorkOrder"; final SearchWorkOrder workOrder; - const CreateSubWorkOrderPage({this.workOrder, Key key}) : super(key: key); + const CreateSubWorkOrderPage({this.workOrder, Key? key}) : super(key: key); @override State createState() => _CreateSubWorkOrderPageState(); diff --git a/lib/views/pages/sub_workorder/search_sub_workorder_page.dart b/lib/views/pages/sub_workorder/search_sub_workorder_page.dart index fb08ab25..f5e570c9 100644 --- a/lib/views/pages/sub_workorder/search_sub_workorder_page.dart +++ b/lib/views/pages/sub_workorder/search_sub_workorder_page.dart @@ -24,7 +24,7 @@ // class SearchSubWorkOrderPage extends StatefulWidget { // static String id = "/SubWorkOrderPage"; // -// const SearchSubWorkOrderPage({Key key}) : super(key: key); +// const SearchSubWorkOrderPage({Key? key}) : super(key: key); // // @override // State createState() => _SearchSubWorkOrderPageState(); diff --git a/lib/views/pages/sub_workorder/spare_parts_details_bottom_sheet.dart b/lib/views/pages/sub_workorder/spare_parts_details_bottom_sheet.dart index 22b195c1..b4400cea 100644 --- a/lib/views/pages/sub_workorder/spare_parts_details_bottom_sheet.dart +++ b/lib/views/pages/sub_workorder/spare_parts_details_bottom_sheet.dart @@ -14,7 +14,7 @@ // final SearchWorkOrder subWorkOrder; // final num assetId; // -// const SparePartsBottomSheet({this.subWorkOrder, this.assetId, Key key}) : super(key: key); +// const SparePartsBottomSheet({this.subWorkOrder, this.assetId, Key? key}) : super(key: key); // // @override // State createState() => _SparePartsBottomSheetState(); diff --git a/lib/views/pages/sub_workorder/work_order_details_bottom_sheet.dart b/lib/views/pages/sub_workorder/work_order_details_bottom_sheet.dart index a861035b..d5243872 100644 --- a/lib/views/pages/sub_workorder/work_order_details_bottom_sheet.dart +++ b/lib/views/pages/sub_workorder/work_order_details_bottom_sheet.dart @@ -23,7 +23,7 @@ // final SearchWorkOrder subWorkOrder; // final num assetId; // -// const WorkOrderDetailsBottomSheet({this.subWorkOrder, this.assetId, Key key}) : super(key: key); +// const WorkOrderDetailsBottomSheet({this.subWorkOrder, this.assetId, Key? key}) : super(key: key); // // @override // State createState() => _WorkOrderDetailsBottomSheetState(); diff --git a/lib/views/pages/sub_workorder/workorder_details.dart b/lib/views/pages/sub_workorder/workorder_details.dart index 0d66cc7b..c4a45a1f 100644 --- a/lib/views/pages/sub_workorder/workorder_details.dart +++ b/lib/views/pages/sub_workorder/workorder_details.dart @@ -11,7 +11,7 @@ // final SearchWorkOrder item; // final Lookup assetType; // -// const WorkOrderDetails({@required this.item, this.assetType, Key key}) : super(key: key); +// const WorkOrderDetails({required this.item, this.assetType, Key? key}) : super(key: key); // // @override // Widget build(BuildContext context) { diff --git a/lib/views/pages/sub_workorder/workorder_item.dart b/lib/views/pages/sub_workorder/workorder_item.dart index 68f54f29..b6288a1b 100644 --- a/lib/views/pages/sub_workorder/workorder_item.dart +++ b/lib/views/pages/sub_workorder/workorder_item.dart @@ -12,7 +12,7 @@ // final SearchWorkOrder item; // final Function(SearchWorkOrder) onPressed; // -// const WorkOrderItem({Key key, this.item, this.onPressed, this.index}) : super(key: key); +// const WorkOrderItem({Key? key, this.item, this.onPressed, this.index}) : super(key: key); // // @override // Widget build(BuildContext context) { diff --git a/lib/views/pages/sub_workorder/workorder_list.dart b/lib/views/pages/sub_workorder/workorder_list.dart index e2ed4d92..3be48a19 100644 --- a/lib/views/pages/sub_workorder/workorder_list.dart +++ b/lib/views/pages/sub_workorder/workorder_list.dart @@ -15,7 +15,7 @@ // List items; // final Future> Function() onLazyLoading; // -// WorkOrderList({Key key, this.items, this.onLazyLoading}) : super(key: key); +// WorkOrderList({Key? key, this.items, this.onLazyLoading}) : super(key: key); // // @override // State createState() => _WorkOrderListState(); diff --git a/lib/views/pages/sub_workorder/workorder_update.dart b/lib/views/pages/sub_workorder/workorder_update.dart index 4c34de4a..ac023e3c 100644 --- a/lib/views/pages/sub_workorder/workorder_update.dart +++ b/lib/views/pages/sub_workorder/workorder_update.dart @@ -9,7 +9,7 @@ // class WorkOrderUpdate extends StatefulWidget { // final SearchWorkOrder item; // -// const WorkOrderUpdate({@required this.item, Key key}) : super(key: key); +// const WorkOrderUpdate({required this.item, Key? key}) : super(key: key); // // @override // State createState() => _WorkOrderUpdateState(); diff --git a/lib/views/pages/user/gas_refill/gas_refill_comments.dart b/lib/views/pages/user/gas_refill/gas_refill_comments.dart index 0e8fb797..c5e802cf 100644 --- a/lib/views/pages/user/gas_refill/gas_refill_comments.dart +++ b/lib/views/pages/user/gas_refill/gas_refill_comments.dart @@ -20,7 +20,7 @@ import '../../../widgets/loaders/loading_manager.dart'; class GasRefillCommentsBottomSheet extends StatefulWidget { final String requestId; - const GasRefillCommentsBottomSheet({Key key, @required this.requestId}) : super(key: key); + const GasRefillCommentsBottomSheet({Key? key, required this.requestId}) : super(key: key); @override State createState() => _GasRefillCommentsBottomSheetState(); diff --git a/lib/views/pages/user/gas_refill/gas_refill_details.dart b/lib/views/pages/user/gas_refill/gas_refill_details.dart index c7dc13a0..f1f1e844 100644 --- a/lib/views/pages/user/gas_refill/gas_refill_details.dart +++ b/lib/views/pages/user/gas_refill/gas_refill_details.dart @@ -23,7 +23,7 @@ class GasRefillDetailsPage extends StatefulWidget { GasRefillModel model; String priority, date; - GasRefillDetailsPage({Key key, this.priority, this.date, this.model}) : super(key: key); + GasRefillDetailsPage({Key? key, this.priority, this.date, this.model}) : super(key: key); @override State createState() => _GasRefillDetailsPageState(); diff --git a/lib/views/pages/user/gas_refill/request_gas_refill.dart b/lib/views/pages/user/gas_refill/request_gas_refill.dart index 1c1bba89..2fd8c745 100644 --- a/lib/views/pages/user/gas_refill/request_gas_refill.dart +++ b/lib/views/pages/user/gas_refill/request_gas_refill.dart @@ -32,7 +32,7 @@ class RequestGasRefill extends StatefulWidget { static const String id = "/request-gas-refill"; final GasRefillModel gasRefillModel; - const RequestGasRefill({this.gasRefillModel, Key key}) : super(key: key); + const RequestGasRefill({this.gasRefillModel, Key? key}) : super(key: key); @override State createState() => _RequestGasRefillState(); diff --git a/lib/views/pages/user/gas_refill/track_gas_refill.dart b/lib/views/pages/user/gas_refill/track_gas_refill.dart index 2056e8dd..7ae9867f 100644 --- a/lib/views/pages/user/gas_refill/track_gas_refill.dart +++ b/lib/views/pages/user/gas_refill/track_gas_refill.dart @@ -12,7 +12,7 @@ import '../../../../new_views/common_widgets/default_app_bar.dart'; class TrackGasRefillPage extends StatefulWidget { static const String id = "/track-gas-refill"; - const TrackGasRefillPage({Key key}) : super(key: key); + const TrackGasRefillPage({Key? key}) : super(key: key); @override State createState() => _TrackGasRefillPageState(); diff --git a/lib/views/pages/user/land_page.dart b/lib/views/pages/user/land_page.dart index ca412ed4..198ba167 100644 --- a/lib/views/pages/user/land_page.dart +++ b/lib/views/pages/user/land_page.dart @@ -26,7 +26,7 @@ // class LandPage extends StatefulWidget { // static const String id = "/old-land-page"; // -// const LandPage({Key key}) : super(key: key); +// const LandPage({Key? key}) : super(key: key); // // @override // State createState() => _LandPageState(); diff --git a/lib/views/pages/user/notifications/notifications_list.dart b/lib/views/pages/user/notifications/notifications_list.dart index fcd9516b..3fc9ecdf 100644 --- a/lib/views/pages/user/notifications/notifications_list.dart +++ b/lib/views/pages/user/notifications/notifications_list.dart @@ -12,7 +12,7 @@ class NotificationsList extends StatelessWidget { final bool nextPage; final Future Function() onLazyLoad; - const NotificationsList({Key key, this.notifications, this.nextPage, this.onLazyLoad}) : super(key: key); + const NotificationsList({Key? key, this.notifications, this.nextPage, this.onLazyLoad}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/views/pages/user/ppm/ppm_details_page.dart b/lib/views/pages/user/ppm/ppm_details_page.dart index c5430262..d530ddd4 100644 --- a/lib/views/pages/user/ppm/ppm_details_page.dart +++ b/lib/views/pages/user/ppm/ppm_details_page.dart @@ -23,7 +23,7 @@ class PpmDetailsPage extends StatefulWidget { static const String id = "/visit-details"; final RequestsDetails request; - PpmDetailsPage({Key key, this.request}) : super(key: key); + PpmDetailsPage({Key? key, this.request}) : super(key: key); @override _PpmDetailsPageState createState() { diff --git a/lib/views/pages/user/ppm/ppm_page.dart b/lib/views/pages/user/ppm/ppm_page.dart index fc46e875..7a24acea 100644 --- a/lib/views/pages/user/ppm/ppm_page.dart +++ b/lib/views/pages/user/ppm/ppm_page.dart @@ -15,7 +15,7 @@ import '../../../widgets/ppm/ppm_item.dart'; class PpmPage extends StatefulWidget { static const String id = "/ppm_page"; - const PpmPage({Key key}) : super(key: key); + const PpmPage({Key? key}) : super(key: key); @override _PpmPageState createState() => _PpmPageState(); diff --git a/lib/views/pages/user/ppm/update_ppm/edit_ppm.dart b/lib/views/pages/user/ppm/update_ppm/edit_ppm.dart index 99759f08..21c98aea 100644 --- a/lib/views/pages/user/ppm/update_ppm/edit_ppm.dart +++ b/lib/views/pages/user/ppm/update_ppm/edit_ppm.dart @@ -22,7 +22,7 @@ class EditPpm extends StatefulWidget { final Ppm ppm; final RequestsDetails details; - const EditPpm({Key key, this.ppm, this.details}) : super(key: key); + const EditPpm({Key? key, this.ppm, this.details}) : super(key: key); @override State createState() => _EditPpmState(); diff --git a/lib/views/pages/user/ppm/update_ppm/future_edit_ppm.dart b/lib/views/pages/user/ppm/update_ppm/future_edit_ppm.dart index 9eb121ae..af6f5619 100644 --- a/lib/views/pages/user/ppm/update_ppm/future_edit_ppm.dart +++ b/lib/views/pages/user/ppm/update_ppm/future_edit_ppm.dart @@ -8,7 +8,7 @@ // class FutureEditPpm extends StatefulWidget { // final Ppm ppm; // -// const FutureEditPpm({Key key, this.ppm}) : super(key: key); +// const FutureEditPpm({Key? key, this.ppm}) : super(key: key); // // @override // State createState() => _FutureEditPpmState(); diff --git a/lib/views/pages/user/profile_page.dart b/lib/views/pages/user/profile_page.dart index 6ed7f80b..8cf64fda 100644 --- a/lib/views/pages/user/profile_page.dart +++ b/lib/views/pages/user/profile_page.dart @@ -18,7 +18,7 @@ import '../../../new_views/app_style/app_color.dart'; class ProfilePage extends StatefulWidget { static const String id = "/user/profile"; - const ProfilePage({Key key}) : super(key: key); + const ProfilePage({Key? key}) : super(key: key); @override _ProfilePageState createState() => _ProfilePageState(); diff --git a/lib/views/pages/user/report_issues_page.dart b/lib/views/pages/user/report_issues_page.dart index 652b5c35..bb934eb4 100644 --- a/lib/views/pages/user/report_issues_page.dart +++ b/lib/views/pages/user/report_issues_page.dart @@ -19,7 +19,7 @@ class ReportIssuesPage extends StatefulWidget { static final String id = "/report-issue"; final ServiceRequest serviceRequest; - const ReportIssuesPage({Key key, this.serviceRequest}) : super(key: key); + const ReportIssuesPage({Key? key, this.serviceRequest}) : super(key: key); @override _ReportIssuesPageState createState() => _ReportIssuesPageState(); diff --git a/lib/views/pages/user/requests/add_supplier_engineer_bottom_sheet.dart b/lib/views/pages/user/requests/add_supplier_engineer_bottom_sheet.dart index 584fa7ae..68bb029a 100644 --- a/lib/views/pages/user/requests/add_supplier_engineer_bottom_sheet.dart +++ b/lib/views/pages/user/requests/add_supplier_engineer_bottom_sheet.dart @@ -21,7 +21,7 @@ import '../../../../new_views/common_widgets/single_item_drop_down_menu.dart'; class AddSupplierEngineerBottomSheet extends StatefulWidget { final int supplierId; - const AddSupplierEngineerBottomSheet(this.supplierId, {Key key}) : super(key: key); + const AddSupplierEngineerBottomSheet(this.supplierId, {Key? key}) : super(key: key); @override State createState() => _AddSupplierEngineerBottomSheetState(); diff --git a/lib/views/pages/user/requests/comments_bottom_sheet.dart b/lib/views/pages/user/requests/comments_bottom_sheet.dart index 4db9dde2..8881cebf 100644 --- a/lib/views/pages/user/requests/comments_bottom_sheet.dart +++ b/lib/views/pages/user/requests/comments_bottom_sheet.dart @@ -20,7 +20,7 @@ import '../../../widgets/loaders/loading_manager.dart'; class CommentsBottomSheet extends StatefulWidget { final String requestId; - const CommentsBottomSheet({Key key, @required this.requestId}) : super(key: key); + const CommentsBottomSheet({Key? key, required this.requestId}) : super(key: key); @override State createState() => _CommentsBottomSheetState(); diff --git a/lib/views/pages/user/requests/create_service_request_page.dart b/lib/views/pages/user/requests/create_service_request_page.dart index 06c61199..e78412c8 100644 --- a/lib/views/pages/user/requests/create_service_request_page.dart +++ b/lib/views/pages/user/requests/create_service_request_page.dart @@ -31,7 +31,7 @@ class CreateServiceRequestPage extends StatefulWidget { static const String id = "/create-request"; final ServiceRequest serviceRequest; - const CreateServiceRequestPage({this.serviceRequest, Key key}) : super(key: key); + const CreateServiceRequestPage({this.serviceRequest, Key? key}) : super(key: key); @override CreateServiceRequestPageState createState() => CreateServiceRequestPageState(); @@ -318,7 +318,7 @@ class CreateServiceRequestPageState extends State { // ), 8.height, TextSpeechRecordWidget( - initialMessage: _serviceRequest.callComments, + initialMessage: _serviceRequest.callComments!, onMessageChange: (message) { _serviceRequest.callComments = message; }, diff --git a/lib/views/pages/user/requests/first_action_bottom_sheet.dart b/lib/views/pages/user/requests/first_action_bottom_sheet.dart index 3046d2ff..bba25d73 100644 --- a/lib/views/pages/user/requests/first_action_bottom_sheet.dart +++ b/lib/views/pages/user/requests/first_action_bottom_sheet.dart @@ -22,7 +22,7 @@ import '../../../widgets/date_and_time/date_picker.dart'; class FirstActionBottomSheet extends StatefulWidget { final ServiceRequest request; - const FirstActionBottomSheet({Key key, @required this.request}) : super(key: key); + const FirstActionBottomSheet({Key? key, required this.request}) : super(key: key); @override State createState() => _FirstActionBottomSheetState(); diff --git a/lib/views/pages/user/requests/pending_requests_screen.dart b/lib/views/pages/user/requests/pending_requests_screen.dart index 30737d59..9faa0911 100644 --- a/lib/views/pages/user/requests/pending_requests_screen.dart +++ b/lib/views/pages/user/requests/pending_requests_screen.dart @@ -12,7 +12,7 @@ import 'package:test_sa/views/widgets/sound/sound_player.dart'; class PendingServiceRequestScreen extends StatelessWidget { final PendingAssetServiceRequest pendingAssetServiceRequest; - PendingServiceRequestScreen(this.pendingAssetServiceRequest, {Key key}) : super(key: key); + PendingServiceRequestScreen(this.pendingAssetServiceRequest, {Key? key}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/views/pages/user/requests/service_request_details.dart b/lib/views/pages/user/requests/service_request_details.dart index 75affc48..24b7f417 100644 --- a/lib/views/pages/user/requests/service_request_details.dart +++ b/lib/views/pages/user/requests/service_request_details.dart @@ -27,7 +27,7 @@ class ServiceRequestDetailsPage extends StatefulWidget { static const String id = "/call-details"; ServiceRequest serviceRequest; - ServiceRequestDetailsPage({Key key, this.serviceRequest}) : super(key: key); + ServiceRequestDetailsPage({Key? key, this.serviceRequest}) : super(key: key); @override State createState() => _ServiceRequestDetailsPageState(); diff --git a/lib/views/pages/user/requests/update_service_request_page.dart b/lib/views/pages/user/requests/update_service_request_page.dart index 071f15f8..2aa2427a 100644 --- a/lib/views/pages/user/requests/update_service_request_page.dart +++ b/lib/views/pages/user/requests/update_service_request_page.dart @@ -30,7 +30,7 @@ class UpdateServiceRequestPage extends StatefulWidget { static const String id = "/update_service_request_page"; final ServiceRequest serviceRequest; - const UpdateServiceRequestPage({Key key, this.serviceRequest}) : super(key: key); + const UpdateServiceRequestPage({Key? key, this.serviceRequest}) : super(key: key); @override State createState() => _UpdateServiceRequestPageState(); diff --git a/lib/views/pages/user/requests/work_order/create_service_report.dart b/lib/views/pages/user/requests/work_order/create_service_report.dart index 134a5235..d2d74283 100644 --- a/lib/views/pages/user/requests/work_order/create_service_report.dart +++ b/lib/views/pages/user/requests/work_order/create_service_report.dart @@ -44,7 +44,7 @@ class CreateServiceReport extends StatefulWidget { static const String id = "/create-service-report"; final ServiceRequest request; - const CreateServiceReport({Key key, this.request}) : super(key: key); + const CreateServiceReport({Key? key, this.request}) : super(key: key); @override _CreateServiceReportState createState() => _CreateServiceReportState(); @@ -98,7 +98,7 @@ class _CreateServiceReportState extends State with TickerPr _isLoading = true; setState(() {}); _serviceReport.callRequest = await _serviceRequestsProvider.getCallRequestForWorkOrder(callId: widget.request.id); - await _assetTypeProvider.getTypes(user: _userProvider.user, host: _settingProvider.host); + await _assetTypeProvider.getTypes(); _serviceReport.assignedEmployee = _serviceReport.callRequest?.assignedEmployee; _serviceReport.equipmentStatus = _serviceReport.callRequest?.defectType; _serviceReport.serviceType = Lookup(id: 65, name: "Interval", value: 1); // default value in service type as in web @@ -209,7 +209,7 @@ class _CreateServiceReportState extends State with TickerPr stateCode: _assetTypeProvider.stateCode, onRefresh: () async { _assetTypeProvider.reset(); - await _assetTypeProvider.getTypes(user: _userProvider.user, host: _settingProvider.host); + await _assetTypeProvider.getTypes(); _serviceReport?.assetType = _assetTypeProvider.statuses?.firstWhere( (element) => element.value == _serviceReport.callRequest.assetType, orElse: () => null, diff --git a/lib/views/pages/user/requests/work_order/edit_service_report.dart b/lib/views/pages/user/requests/work_order/edit_service_report.dart index 8f756da1..35ffe975 100644 --- a/lib/views/pages/user/requests/work_order/edit_service_report.dart +++ b/lib/views/pages/user/requests/work_order/edit_service_report.dart @@ -14,7 +14,6 @@ import 'package:test_sa/extensions/widget_extensions.dart'; import 'package:test_sa/models/device/asset.dart'; import 'package:test_sa/models/service_request/service_report.dart'; import 'package:test_sa/models/service_request/service_request.dart'; -import 'package:test_sa/new_views/common_widgets/asset_info_card.dart'; import 'package:test_sa/providers/service_request_providers/loan_availability_provider.dart'; import 'package:test_sa/views/pages/user/requests/work_order/part_no_button.dart'; import 'package:test_sa/views/widgets/equipment/pick_asset.dart'; @@ -45,7 +44,7 @@ class EditServiceReport extends StatefulWidget { final ServiceRequest request; final ServiceReport report; - const EditServiceReport({Key key, this.request, this.report}) : super(key: key); + const EditServiceReport({Key? key, this.request, this.report}) : super(key: key); @override _EditServiceReportState createState() => _EditServiceReportState(); @@ -86,7 +85,7 @@ class _EditServiceReportState extends State with TickerProvid setState(() {}); _callRequestForWorkOrder = await _serviceRequestsProvider?.getCallRequestForWorkOrder(callId: widget.request.id); _serviceReport.assignedEmployee = _callRequestForWorkOrder?.assignedEmployee; - await _assetTypeProvider?.getTypes(user: _userProvider.user, host: _settingProvider.host); + await _assetTypeProvider.getTypes(); _isLoading = false; setState(() {}); } @@ -183,7 +182,7 @@ class _EditServiceReportState extends State with TickerProvid stateCode: _assetTypeProvider.stateCode, onRefresh: () async { _assetTypeProvider.reset(); - await _assetTypeProvider.getTypes(user: _userProvider.user, host: _settingProvider.host); + await _assetTypeProvider.getTypes(); _serviceReport?.assetType = _assetTypeProvider.statuses?.firstWhere( (element) => element.value == _serviceReport.callRequest.assetType, orElse: () => null, diff --git a/lib/views/pages/user/requests/work_order/part_no_button.dart b/lib/views/pages/user/requests/work_order/part_no_button.dart index d06ed373..cd16097c 100644 --- a/lib/views/pages/user/requests/work_order/part_no_button.dart +++ b/lib/views/pages/user/requests/work_order/part_no_button.dart @@ -19,7 +19,7 @@ class PartNoButton extends StatefulWidget { final bool disablePartEdit; final Function(List sparePart) onChange; - const PartNoButton({@required this.spareParts, @required this.controller, this.initialList, this.onChange, this.disablePartEdit = false, Key key}) : super(key: key); + const PartNoButton({required this.spareParts, required this.controller, this.initialList, this.onChange, this.disablePartEdit = false, Key? key}) : super(key: key); @override State createState() => _PartNoButtonState(); diff --git a/lib/views/pages/user/requests/work_order/update_service_report.dart b/lib/views/pages/user/requests/work_order/update_service_report.dart index fb8bcee7..b972a63d 100644 --- a/lib/views/pages/user/requests/work_order/update_service_report.dart +++ b/lib/views/pages/user/requests/work_order/update_service_report.dart @@ -12,7 +12,7 @@ class UpdateServiceReport extends StatefulWidget { final ServiceRequest request; final SearchWorkOrder workOrder; - const UpdateServiceReport({Key key, this.request, this.workOrder}) : super(key: key); + const UpdateServiceReport({Key? key, this.request, this.workOrder}) : super(key: key); @override _UpdateServiceReportState createState() => _UpdateServiceReportState(); diff --git a/lib/views/pages/user/requests/work_order/work_order_details_page.dart b/lib/views/pages/user/requests/work_order/work_order_details_page.dart index d711c931..197ac228 100644 --- a/lib/views/pages/user/requests/work_order/work_order_details_page.dart +++ b/lib/views/pages/user/requests/work_order/work_order_details_page.dart @@ -26,7 +26,7 @@ class WorkOrderDetailsPage extends StatelessWidget { final SearchWorkOrder workOrder; final ServiceRequest serviceRequest; - const WorkOrderDetailsPage({Key key, this.workOrder, this.serviceRequest}) : super(key: key); + const WorkOrderDetailsPage({Key? key, this.workOrder, this.serviceRequest}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/views/pages/user/requests/work_order/work_orders_list_page.dart b/lib/views/pages/user/requests/work_order/work_orders_list_page.dart index b29e2383..4183f7a9 100644 --- a/lib/views/pages/user/requests/work_order/work_orders_list_page.dart +++ b/lib/views/pages/user/requests/work_order/work_orders_list_page.dart @@ -24,7 +24,7 @@ class WorkOrderListPage extends StatelessWidget { static const String id = "/work-order-list"; ServiceRequest serviceRequest; - WorkOrderListPage({Key key, this.serviceRequest}) : super(key: key); + WorkOrderListPage({Key? key, this.serviceRequest}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/views/widgets/buttons/app_back_button.dart b/lib/views/widgets/buttons/app_back_button.dart index 99394548..06708ca0 100644 --- a/lib/views/widgets/buttons/app_back_button.dart +++ b/lib/views/widgets/buttons/app_back_button.dart @@ -6,7 +6,7 @@ class ABackButton extends StatelessWidget { final VoidCallback onPressed; final IconData icon; - const ABackButton({Key key, this.onPressed, this.icon}) : super(key: key); + const ABackButton({Key? key, this.onPressed, this.icon}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/views/widgets/buttons/app_button.dart b/lib/views/widgets/buttons/app_button.dart index f5efd4a7..55306a41 100644 --- a/lib/views/widgets/buttons/app_button.dart +++ b/lib/views/widgets/buttons/app_button.dart @@ -9,7 +9,7 @@ class AButton extends StatelessWidget { final TextStyle textStyle; final VoidCallback onPressed; - const AButton({Key key, this.color /* = AColors.primaryColor*/, this.text, this.padding, this.onPressed, this.textStyle}) : super(key: key); + const AButton({Key? key, this.color /* = AColors.primaryColor*/, this.text, this.padding, this.onPressed, this.textStyle}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/views/widgets/buttons/app_flat_button.dart b/lib/views/widgets/buttons/app_flat_button.dart index 7f6b652a..6fdc3dbc 100644 --- a/lib/views/widgets/buttons/app_flat_button.dart +++ b/lib/views/widgets/buttons/app_flat_button.dart @@ -9,7 +9,7 @@ // final EdgeInsets padding; // final VoidCallback onPressed; // -// const AFlatButton({Key key, this.text, this.textColor, this.style, this.onPressed, this.padding}) : super(key: key); +// const AFlatButton({Key? key, this.text, this.textColor, this.style, this.onPressed, this.padding}) : super(key: key); // // @override // Widget build(BuildContext context) { diff --git a/lib/views/widgets/buttons/app_icon_button.dart b/lib/views/widgets/buttons/app_icon_button.dart index 3c69096c..198a8d91 100644 --- a/lib/views/widgets/buttons/app_icon_button.dart +++ b/lib/views/widgets/buttons/app_icon_button.dart @@ -10,7 +10,7 @@ class AIconButton extends StatelessWidget { final double iconSize; final double buttonSize; - const AIconButton({Key key, this.iconData, this.onPressed, this.color, this.iconSize, this.buttonSize = 54, this.backgroundColor}) : super(key: key); + const AIconButton({Key? key, this.iconData, this.onPressed, this.color, this.iconSize, this.buttonSize = 54, this.backgroundColor}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/views/widgets/buttons/app_icon_button2.dart b/lib/views/widgets/buttons/app_icon_button2.dart index 1726a375..fff4421d 100644 --- a/lib/views/widgets/buttons/app_icon_button2.dart +++ b/lib/views/widgets/buttons/app_icon_button2.dart @@ -8,7 +8,7 @@ class AIconButton2 extends StatelessWidget { final VoidCallback onPressed; const AIconButton2({ - Key key, + Key? key, this.iconData, this.onPressed, this.color, diff --git a/lib/views/widgets/buttons/app_outlined_button.dart b/lib/views/widgets/buttons/app_outlined_button.dart index cb8eda7d..163ed24e 100644 --- a/lib/views/widgets/buttons/app_outlined_button.dart +++ b/lib/views/widgets/buttons/app_outlined_button.dart @@ -9,7 +9,7 @@ // final TextStyle textStyle; // final VoidCallback onPressed; // -// const AOutLinedButton({Key key, this.color/*= AColors.primaryColor*/, this.text, this.padding, this.onPressed, this.textStyle}) : super(key: key); +// const AOutLinedButton({Key? key, this.color/*= AColors.primaryColor*/, this.text, this.padding, this.onPressed, this.textStyle}) : super(key: key); // // @override // Widget build(BuildContext context) { diff --git a/lib/views/widgets/buttons/app_small_button.dart b/lib/views/widgets/buttons/app_small_button.dart index 0613ef9c..30c3d5a0 100644 --- a/lib/views/widgets/buttons/app_small_button.dart +++ b/lib/views/widgets/buttons/app_small_button.dart @@ -9,7 +9,7 @@ // final EdgeInsets padding; // final VoidCallback onPressed; // -// const ASmallButton({Key key, this.text, this.style, this.onPressed, this.padding, this.color}) : super(key: key); +// const ASmallButton({Key? key, this.text, this.style, this.onPressed, this.padding, this.color}) : super(key: key); // // @override // Widget build(BuildContext context) { diff --git a/lib/views/widgets/buttons/rounded_back_button.dart b/lib/views/widgets/buttons/rounded_back_button.dart index 4a5d9755..f05e8b1d 100644 --- a/lib/views/widgets/buttons/rounded_back_button.dart +++ b/lib/views/widgets/buttons/rounded_back_button.dart @@ -6,7 +6,7 @@ class RoundedBackButton extends StatelessWidget { final Color backgroundColor; final Color iconColor; - const RoundedBackButton({Key key, this.onPressed,@required this.icon,this.backgroundColor,this.iconColor}) : super(key: key); + const RoundedBackButton({Key? key, this.onPressed,required this.icon,this.backgroundColor,this.iconColor}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/views/widgets/date_and_time/date_picker.dart b/lib/views/widgets/date_and_time/date_picker.dart index 8fa843b8..f4387c61 100644 --- a/lib/views/widgets/date_and_time/date_picker.dart +++ b/lib/views/widgets/date_and_time/date_picker.dart @@ -7,25 +7,26 @@ import 'package:test_sa/extensions/widget_extensions.dart'; import 'package:test_sa/new_views/app_style/app_color.dart'; class ADatePicker extends StatelessWidget { - final DateTime date; - final DateTime from; - final DateTime to; + final DateTime? date; // Nullable + final DateTime? from; // Nullable + final DateTime? to; // Nullable final String label; final bool hideShadow; - final String hint; - final Function(DateTime) onDatePicker; - final bool enable, withBorder; - final Color backgroundColor; + final String? hint; // Nullable + final Function(DateTime)? onDatePicker; // Nullable + final bool enable; + final bool withBorder; + final Color? backgroundColor; // Nullable final bool formatDateWithTime; - final double height; + final double? height; // Nullable const ADatePicker({ - Key key, - @required this.label, + Key? key, + required this.label, this.withBorder = true, this.height, this.backgroundColor, - this.hideShadow=false, + this.hideShadow = false, this.hint, this.date, this.formatDateWithTime = false, @@ -38,49 +39,51 @@ class ADatePicker extends StatelessWidget { @override Widget build(BuildContext context) { return Container( - height:height, + height: height, decoration: BoxDecoration( color: backgroundColor ?? - (context.isDark && (enable == false) + (context.isDark && !enable ? AppColor.neutral50 - : (enable == false) + : !enable ? AppColor.neutral40 : AppColor.background(context)), borderRadius: BorderRadius.circular(10), border: withBorder ? Border.all(width: 1, color: Theme.of(context).scaffoldBackgroundColor) : const Border(), - boxShadow: hideShadow?null: [BoxShadow(color: Colors.black.withOpacity(0.05), blurRadius: 10)], + boxShadow: hideShadow ? null : [BoxShadow(color: Colors.black.withOpacity(0.05), blurRadius: 10)], ), padding: EdgeInsets.symmetric(horizontal: 16.toScreenWidth, vertical: 8.toScreenHeight), child: Row( children: [ - // enable - // ? Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - mainAxisSize: MainAxisSize.min, - children: [ - label.tinyFont(context), - (date?.toIso8601String == null - ?hint?? context.translation.pickADate - : (formatDateWithTime ? date?.toIso8601String()?.toFirstActionFormat : (date?.toIso8601String()?.split("T")?.first ?? context.translation.pickADate))) - .bodyText(context) - .custom(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50), - ], - ).expanded, - //: label.bodyText(context).paddingOnly(top: 8, bottom: 8), + crossAxisAlignment: CrossAxisAlignment.stretch, + mainAxisSize: MainAxisSize.min, + children: [ + label.tinyFont(context), + (date == null + ? hint ?? context.translation.pickADate + : (formatDateWithTime + ? date?.toIso8601String()?.toFirstActionFormat // Use null-aware operator + : (date?.toIso8601String()?.split("T")?.first ?? context.translation.pickADate)))! + .bodyText(context) + .custom(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50), + ], + ).expanded, enable ? 16.width : const Spacer(), "calender".toSvgAsset(width: 20, color: context.isDark ? AppColor.neutral10 : null), ], ), ).onPress(enable ? () async { - DateTime picked = await showDatePicker( + final DateTime? picked = await showDatePicker( + // Nullable DateTime context: context, initialDate: DateTime.now(), firstDate: from ?? DateTime.now(), lastDate: to ?? DateTime.now().add(const Duration(days: 365)), ); - if (onDatePicker != null) onDatePicker(picked); + if (picked != null && onDatePicker != null) { + onDatePicker!(picked); // Use null-aware operator + } } : null); } diff --git a/lib/views/widgets/date_and_time/from_to_date_bar.dart b/lib/views/widgets/date_and_time/from_to_date_bar.dart index 0f1c543a..717b7b58 100644 --- a/lib/views/widgets/date_and_time/from_to_date_bar.dart +++ b/lib/views/widgets/date_and_time/from_to_date_bar.dart @@ -11,7 +11,7 @@ // final Function(DateTime) onPickFrom; // final Function(DateTime) onPickTo; // -// const FromToDateBar({Key key, this.from, this.to, this.onPickFrom, this.onPickTo}) : super(key: key); +// const FromToDateBar({Key? key, this.from, this.to, this.onPickFrom, this.onPickTo}) : super(key: key); // // @override // _FromToDateBarState createState() => _FromToDateBarState(); diff --git a/lib/views/widgets/date_and_time/time_picker.dart b/lib/views/widgets/date_and_time/time_picker.dart index 2752d455..d1b2b2cf 100644 --- a/lib/views/widgets/date_and_time/time_picker.dart +++ b/lib/views/widgets/date_and_time/time_picker.dart @@ -16,8 +16,8 @@ class ATimePicker extends StatelessWidget { final double height; const ATimePicker({ - Key key, - @required this.label, + Key? key, + required this.label, this.withBorder = true, this.height, this.backgroundColor, diff --git a/lib/views/widgets/departments/department_button.dart b/lib/views/widgets/departments/department_button.dart index 5278aa26..2a02fc8a 100644 --- a/lib/views/widgets/departments/department_button.dart +++ b/lib/views/widgets/departments/department_button.dart @@ -9,7 +9,7 @@ // final Function(Department) onDepartmentPick; // final Department department; // -// const DepartmentButton({Key key, this.department, this.onDepartmentPick}) : super(key: key); +// const DepartmentButton({Key? key, this.department, this.onDepartmentPick}) : super(key: key); // // @override // Widget build(BuildContext context) { diff --git a/lib/views/widgets/departments/department_item.dart b/lib/views/widgets/departments/department_item.dart index db8c4466..17119878 100644 --- a/lib/views/widgets/departments/department_item.dart +++ b/lib/views/widgets/departments/department_item.dart @@ -6,7 +6,7 @@ class DepartmentItem extends StatelessWidget { final Department department; final Function(Department) onPressed; - const DepartmentItem({Key key, this.department, this.onPressed}) : super(key: key); + const DepartmentItem({Key? key, this.department, this.onPressed}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/views/widgets/device_trancfer/device_transfer_info_section.dart b/lib/views/widgets/device_trancfer/device_transfer_info_section.dart index f8544660..3d5ad34f 100644 --- a/lib/views/widgets/device_trancfer/device_transfer_info_section.dart +++ b/lib/views/widgets/device_trancfer/device_transfer_info_section.dart @@ -15,7 +15,7 @@ // final bool isSender; // final VoidCallback onEdit; // -// const DeviceTransferInfoSection({Key key, this.info, this.onEdit, this.isSender}) : super(key: key); +// const DeviceTransferInfoSection({Key? key, this.info, this.onEdit, this.isSender}) : super(key: key); // // @override // Widget build(BuildContext context) { diff --git a/lib/views/widgets/device_trancfer/device_transfer_item.dart b/lib/views/widgets/device_trancfer/device_transfer_item.dart index 695fc255..bfdc2363 100644 --- a/lib/views/widgets/device_trancfer/device_transfer_item.dart +++ b/lib/views/widgets/device_trancfer/device_transfer_item.dart @@ -13,7 +13,7 @@ class DeviceTransferItem extends StatelessWidget { final AssetTransfer item; final Function(AssetTransfer) onPressed; - const DeviceTransferItem({Key key, this.item, this.onPressed, this.index}) : super(key: key); + const DeviceTransferItem({Key? key, this.item, this.onPressed, this.index}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/views/widgets/device_trancfer/device_transfer_list.dart b/lib/views/widgets/device_trancfer/device_transfer_list.dart index bcc6a3c2..fa5f542f 100644 --- a/lib/views/widgets/device_trancfer/device_transfer_list.dart +++ b/lib/views/widgets/device_trancfer/device_transfer_list.dart @@ -11,7 +11,7 @@ class DeviceTransferList extends StatelessWidget { final bool nextPage; final Future Function() onLazyLoad; - const DeviceTransferList({Key key, this.items, this.nextPage, this.onLazyLoad}) : super(key: key); + const DeviceTransferList({Key? key, this.items, this.nextPage, this.onLazyLoad}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/views/widgets/dialogs/dialog.dart b/lib/views/widgets/dialogs/dialog.dart index 0832ca24..473c2a69 100644 --- a/lib/views/widgets/dialogs/dialog.dart +++ b/lib/views/widgets/dialogs/dialog.dart @@ -6,7 +6,7 @@ class AAlertDialog extends StatelessWidget { final String title; final String content; - const AAlertDialog({Key key, this.title, this.content}) : super(key: key); + const AAlertDialog({Key? key, this.title, this.content}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/views/widgets/drawer/drawer_item.dart b/lib/views/widgets/drawer/drawer_item.dart index 3a4e47d8..95fe38f9 100644 --- a/lib/views/widgets/drawer/drawer_item.dart +++ b/lib/views/widgets/drawer/drawer_item.dart @@ -9,7 +9,7 @@ // final IconData icon; // final VoidCallback onPressed; // -// const DrawerItem({Key key, this.title, this.icon, this.onPressed}) : super(key: key); +// const DrawerItem({Key? key, this.title, this.icon, this.onPressed}) : super(key: key); // // @override // Widget build(BuildContext context) { diff --git a/lib/views/widgets/e_signature/e_signature.dart b/lib/views/widgets/e_signature/e_signature.dart index ec25df33..d40311c6 100644 --- a/lib/views/widgets/e_signature/e_signature.dart +++ b/lib/views/widgets/e_signature/e_signature.dart @@ -17,7 +17,7 @@ class ESignature extends StatefulWidget { final Function(Uint8List) onChange; final String title; - const ESignature({Key key, this.title, this.oldSignature, this.onSaved, this.onChange, this.newSignature}) : super(key: key); + const ESignature({Key? key, this.title, this.oldSignature, this.onSaved, this.onChange, this.newSignature}) : super(key: key); @override State createState() => _ESignatureState(); diff --git a/lib/views/widgets/equipment/asset_detail_page.dart b/lib/views/widgets/equipment/asset_detail_page.dart index 3f6e3beb..41e3ef2e 100644 --- a/lib/views/widgets/equipment/asset_detail_page.dart +++ b/lib/views/widgets/equipment/asset_detail_page.dart @@ -18,7 +18,7 @@ import '../requests/request_status.dart'; class AssetDetailPage extends StatefulWidget { static const String id = "/asset-details"; - AssetDetailPage({Key key}) : super(key: key); + AssetDetailPage({Key? key}) : super(key: key); @override _AssetDetailPageState createState() { diff --git a/lib/views/widgets/equipment/asset_item_gridview.dart b/lib/views/widgets/equipment/asset_item_gridview.dart index 09209cd6..50854733 100644 --- a/lib/views/widgets/equipment/asset_item_gridview.dart +++ b/lib/views/widgets/equipment/asset_item_gridview.dart @@ -12,7 +12,7 @@ class AssetItemGridView extends StatelessWidget { final Asset device; final Function(Asset) onPressed; - const AssetItemGridView({Key key, this.device, this.onPressed}) : super(key: key); + const AssetItemGridView({Key? key, this.device, this.onPressed}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/views/widgets/equipment/asset_item_listview.dart b/lib/views/widgets/equipment/asset_item_listview.dart index aaa0baf8..6b88eacf 100644 --- a/lib/views/widgets/equipment/asset_item_listview.dart +++ b/lib/views/widgets/equipment/asset_item_listview.dart @@ -12,7 +12,7 @@ class AssetItemListView extends StatelessWidget { final Function(Asset) onPressed; final Widget selectButton; - const AssetItemListView({Key key, this.device, this.onPressed, this.selectButton}) : super(key: key); + const AssetItemListView({Key? key, this.device, this.onPressed, this.selectButton}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/views/widgets/equipment/asset_picker.dart b/lib/views/widgets/equipment/asset_picker.dart index 701b8d9e..ceb91c2a 100644 --- a/lib/views/widgets/equipment/asset_picker.dart +++ b/lib/views/widgets/equipment/asset_picker.dart @@ -18,7 +18,7 @@ class AssetPicker extends StatelessWidget { final bool forPPM; final bool showLoading; - AssetPicker({Key key, this.editable = true, this.device, this.onPick, this.showAssetInfo = true, this.forPPM = false, this.showLoading = false}) : super(key: key); + AssetPicker({Key? key, this.editable = true, this.device, this.onPick, this.showAssetInfo = true, this.forPPM = false, this.showLoading = false}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/views/widgets/equipment/auto_complete_devices_field.dart b/lib/views/widgets/equipment/auto_complete_devices_field.dart index 4474d755..1e955627 100644 --- a/lib/views/widgets/equipment/auto_complete_devices_field.dart +++ b/lib/views/widgets/equipment/auto_complete_devices_field.dart @@ -15,7 +15,7 @@ // final int hospitalId; // final Function(int) onPick; // -// const AutoCompleteDeviceField({Key key, this.initialValue, this.onPick, this.hospitalId}) : super(key: key); +// const AutoCompleteDeviceField({Key? key, this.initialValue, this.onPick, this.hospitalId}) : super(key: key); // // @override // _AutoCompleteDeviceFieldState createState() => _AutoCompleteDeviceFieldState(); diff --git a/lib/views/widgets/equipment/auto_complete_models_field.dart b/lib/views/widgets/equipment/auto_complete_models_field.dart index 28c9941f..d672ea3f 100644 --- a/lib/views/widgets/equipment/auto_complete_models_field.dart +++ b/lib/views/widgets/equipment/auto_complete_models_field.dart @@ -13,7 +13,7 @@ // final Function(Lookup) onPick; // // const AutoCompleteModelField({ -// Key key, +// Key? key, // this.initialValue, // this.onPick, // }) : super(key: key); diff --git a/lib/views/widgets/equipment/commissioning_status_buttons.dart b/lib/views/widgets/equipment/commissioning_status_buttons.dart index 35b415f1..9edf8730 100644 --- a/lib/views/widgets/equipment/commissioning_status_buttons.dart +++ b/lib/views/widgets/equipment/commissioning_status_buttons.dart @@ -14,7 +14,7 @@ class CommissioningStatusButtons extends StatefulWidget { final Function(Lookup) onSelect; final Lookup initialValue; - CommissioningStatusButtons({Key key, this.onSelect, this.initialValue}) : super(key: key); + CommissioningStatusButtons({Key? key, this.onSelect, this.initialValue}) : super(key: key); @override State createState() => _CommissioningStatusButtonsState(); @@ -117,7 +117,7 @@ class _CommissioningStatusButtonsState extends State class _Skelton extends StatelessWidget { const _Skelton({ - Key key, + Key? key, }) : super(key: key); @override diff --git a/lib/views/widgets/equipment/single_device_picker.dart b/lib/views/widgets/equipment/single_device_picker.dart index 98ca6dc3..0ef510ed 100644 --- a/lib/views/widgets/equipment/single_device_picker.dart +++ b/lib/views/widgets/equipment/single_device_picker.dart @@ -27,7 +27,7 @@ class MyAssetsPage extends StatefulWidget { static final String id = "/single-device-Picker"; final bool fromBottomBar; - const MyAssetsPage({Key key, this.fromBottomBar = false}) : super(key: key); + const MyAssetsPage({Key? key, this.fromBottomBar = false}) : super(key: key); @override _MyAssetsPageState createState() => _MyAssetsPageState(); diff --git a/lib/views/widgets/gas_refill/building_type_menu.dart b/lib/views/widgets/gas_refill/building_type_menu.dart index 7f4bda93..91e40ea8 100644 --- a/lib/views/widgets/gas_refill/building_type_menu.dart +++ b/lib/views/widgets/gas_refill/building_type_menu.dart @@ -12,7 +12,7 @@ // bool enabled, loading; // // BuildingTypeMenu({ -// Key key, +// Key? key, // this.onSelect, // this.initialValue, // this.building = const [], diff --git a/lib/views/widgets/gas_refill/department_type_menu.dart b/lib/views/widgets/gas_refill/department_type_menu.dart index 5b4cbec5..604ccf5e 100644 --- a/lib/views/widgets/gas_refill/department_type_menu.dart +++ b/lib/views/widgets/gas_refill/department_type_menu.dart @@ -12,7 +12,7 @@ // bool enabled, loading; // // DepartmentTypeMenu({ -// Key key, +// Key? key, // this.onSelect, // this.initialValue, // this.departments = const [], diff --git a/lib/views/widgets/gas_refill/floor_type_menu.dart b/lib/views/widgets/gas_refill/floor_type_menu.dart index 04e36eda..0cb0de2f 100644 --- a/lib/views/widgets/gas_refill/floor_type_menu.dart +++ b/lib/views/widgets/gas_refill/floor_type_menu.dart @@ -13,7 +13,7 @@ // bool loading; // // FloorTypeMenu({ -// Key key, +// Key? key, // this.onSelect, // this.initialValue, // this.floors = const [], diff --git a/lib/views/widgets/gas_refill/gas_refill_create_details_item.dart b/lib/views/widgets/gas_refill/gas_refill_create_details_item.dart index e54a1a03..ac55b884 100644 --- a/lib/views/widgets/gas_refill/gas_refill_create_details_item.dart +++ b/lib/views/widgets/gas_refill/gas_refill_create_details_item.dart @@ -12,7 +12,7 @@ // final VoidCallback onPressed; // final bool isUpdate; // -// const GasRefillCreateDetailsItem({Key key, this.isUpdate, this.model, this.onPressed}) : super(key: key); +// const GasRefillCreateDetailsItem({Key? key, this.isUpdate, this.model, this.onPressed}) : super(key: key); // // @override // State createState() => _GasRefillCreateDetailsItemState(); diff --git a/lib/views/widgets/gas_refill/gas_refill_item.dart b/lib/views/widgets/gas_refill/gas_refill_item.dart index 48bea602..2ab6a566 100644 --- a/lib/views/widgets/gas_refill/gas_refill_item.dart +++ b/lib/views/widgets/gas_refill/gas_refill_item.dart @@ -14,7 +14,7 @@ class GasRefillItem extends StatelessWidget { final GasRefillModel item; final Function(GasRefillModel) onPressed; - const GasRefillItem({Key key, this.item, this.onPressed, this.index}) : super(key: key); + const GasRefillItem({Key? key, this.item, this.onPressed, this.index}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/views/widgets/gas_refill/gas_refill_list.dart b/lib/views/widgets/gas_refill/gas_refill_list.dart index 5bbb3361..71083653 100644 --- a/lib/views/widgets/gas_refill/gas_refill_list.dart +++ b/lib/views/widgets/gas_refill/gas_refill_list.dart @@ -12,7 +12,7 @@ class GasRefillList extends StatefulWidget { final bool nextPage; final Future Function() onLazyLoad; - const GasRefillList({Key key, this.items, this.nextPage, this.onLazyLoad}) : super(key: key); + const GasRefillList({Key? key, this.items, this.nextPage, this.onLazyLoad}) : super(key: key); @override State createState() => _GasRefillListState(); diff --git a/lib/views/widgets/gas_refill/gas_refill_update_details_item.dart b/lib/views/widgets/gas_refill/gas_refill_update_details_item.dart index 6a29dcce..4e22d444 100644 --- a/lib/views/widgets/gas_refill/gas_refill_update_details_item.dart +++ b/lib/views/widgets/gas_refill/gas_refill_update_details_item.dart @@ -14,7 +14,7 @@ // final bool enableEdit; // final bool validate; // -// const GasRefillUpdateDetailsItem({Key key, this.details, this.enableEdit, this.validate}) : super(key: key); +// const GasRefillUpdateDetailsItem({Key? key, this.details, this.enableEdit, this.validate}) : super(key: key); // // @override // Widget build(BuildContext context) { diff --git a/lib/views/widgets/hospitals/hospital_auto_complete_field.dart b/lib/views/widgets/hospitals/hospital_auto_complete_field.dart index 501dbace..94f220d7 100644 --- a/lib/views/widgets/hospitals/hospital_auto_complete_field.dart +++ b/lib/views/widgets/hospitals/hospital_auto_complete_field.dart @@ -15,7 +15,7 @@ // //final Function(Hospital) onSave; // // const HospitalAutoCompleteField({ -// Key key, +// Key? key, // this.onSearch, // this.initialValue, // }) : super(key: key); diff --git a/lib/views/widgets/hospitals/hospital_auto_complete_field_new.dart b/lib/views/widgets/hospitals/hospital_auto_complete_field_new.dart index ed7a9b99..915bf4ba 100644 --- a/lib/views/widgets/hospitals/hospital_auto_complete_field_new.dart +++ b/lib/views/widgets/hospitals/hospital_auto_complete_field_new.dart @@ -17,7 +17,7 @@ // //final Function(Hospital) onSave; // // const HospitalAutoCompleteField({ -// Key key, +// Key? key, // this.onSearch, // this.initialValue, // this.enabled = true, diff --git a/lib/views/widgets/hospitals/hospital_button.dart b/lib/views/widgets/hospitals/hospital_button.dart index 9887f5f4..99be859c 100644 --- a/lib/views/widgets/hospitals/hospital_button.dart +++ b/lib/views/widgets/hospitals/hospital_button.dart @@ -9,7 +9,7 @@ // final Function(Hospital) onHospitalPick; // final Hospital hospital; // -// const HospitalButton({Key key, this.hospital, this.onHospitalPick}) : super(key: key); +// const HospitalButton({Key? key, this.hospital, this.onHospitalPick}) : super(key: key); // // @override // Widget build(BuildContext context) { diff --git a/lib/views/widgets/hospitals/hospital_item.dart b/lib/views/widgets/hospitals/hospital_item.dart index 568de599..aa8c5751 100644 --- a/lib/views/widgets/hospitals/hospital_item.dart +++ b/lib/views/widgets/hospitals/hospital_item.dart @@ -6,7 +6,7 @@ class HospitalItem extends StatelessWidget { final Hospital hospital; final Function(Hospital) onPressed; - const HospitalItem({Key key, this.hospital, this.onPressed}) : super(key: key); + const HospitalItem({Key? key, this.hospital, this.onPressed}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/views/widgets/images/files_list.dart b/lib/views/widgets/images/files_list.dart index 251537f2..7bfb27c4 100644 --- a/lib/views/widgets/images/files_list.dart +++ b/lib/views/widgets/images/files_list.dart @@ -14,7 +14,7 @@ class FilesList extends StatelessWidget { final List images; final EdgeInsets padding; - const FilesList({Key key, this.images, this.padding}) : super(key: key); + const FilesList({Key? key, this.images, this.padding}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/views/widgets/images/image_item.dart b/lib/views/widgets/images/image_item.dart index e39ce0cd..0140b6c1 100644 --- a/lib/views/widgets/images/image_item.dart +++ b/lib/views/widgets/images/image_item.dart @@ -8,7 +8,7 @@ class ImageItem extends StatelessWidget { final bool isVideo; final VoidCallback onPressed; - const ImageItem({Key key, this.url, this.isVideo = false, this.onPressed}) : super(key: key); + const ImageItem({Key? key, this.url, this.isVideo = false, this.onPressed}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/views/widgets/images/images_list.dart b/lib/views/widgets/images/images_list.dart index 75544173..409865db 100644 --- a/lib/views/widgets/images/images_list.dart +++ b/lib/views/widgets/images/images_list.dart @@ -9,7 +9,7 @@ // final List images; // final EdgeInsets padding; // -// const ImagesList({Key key, this.images, this.padding}) : super(key: key); +// const ImagesList({Key? key, this.images, this.padding}) : super(key: key); // // @override // Widget build(BuildContext context) { diff --git a/lib/views/widgets/images/images_viewer.dart b/lib/views/widgets/images/images_viewer.dart index 289a1a21..6f15f6f7 100644 --- a/lib/views/widgets/images/images_viewer.dart +++ b/lib/views/widgets/images/images_viewer.dart @@ -8,7 +8,7 @@ // final int initialIndex; // // const ImagesViewer({ -// Key key, +// Key? key, // this.images, // this.initialIndex = 0, // }) : super(key: key); diff --git a/lib/views/widgets/images/mini_one_file_picker.dart b/lib/views/widgets/images/mini_one_file_picker.dart index 39cb4688..c46e6c6a 100644 --- a/lib/views/widgets/images/mini_one_file_picker.dart +++ b/lib/views/widgets/images/mini_one_file_picker.dart @@ -15,7 +15,7 @@ // final String label; // final bool error; // -// const AMiniOneFilePicker({Key key, this.label, this.error, this.file, this.onPick}) : super(key: key); +// const AMiniOneFilePicker({Key? key, this.label, this.error, this.file, this.onPick}) : super(key: key); // // @override // _AMiniOneFilePickerState createState() => _AMiniOneFilePickerState(); diff --git a/lib/views/widgets/images/multi_image_picker.dart b/lib/views/widgets/images/multi_image_picker.dart index abd00bb3..7df9c61e 100644 --- a/lib/views/widgets/images/multi_image_picker.dart +++ b/lib/views/widgets/images/multi_image_picker.dart @@ -21,7 +21,7 @@ class MultiFilesPicker extends StatefulWidget { final Function(List) onChange; final bool showAsGrid; - const MultiFilesPicker({Key key, this.files, this.label, this.error = false, this.enabled = true, this.onlyImages = false, this.onChange,this.showAsGrid=false}) : super(key: key); + const MultiFilesPicker({Key? key, this.files, this.label, this.error = false, this.enabled = true, this.onlyImages = false, this.onChange,this.showAsGrid=false}) : super(key: key); @override State createState() => _MultiFilesPickerState(); diff --git a/lib/views/widgets/images/multi_image_picker_item.dart b/lib/views/widgets/images/multi_image_picker_item.dart index f0fcb693..8215529f 100644 --- a/lib/views/widgets/images/multi_image_picker_item.dart +++ b/lib/views/widgets/images/multi_image_picker_item.dart @@ -18,7 +18,7 @@ class MultiFilesPickerItem extends StatelessWidget { final bool enabled; final Function(File) onRemoveTap; - const MultiFilesPickerItem({Key key, this.file, this.enabled, this.onRemoveTap}) : super(key: key); + const MultiFilesPickerItem({Key? key, this.file, this.enabled, this.onRemoveTap}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/views/widgets/images/one_image_picker.dart b/lib/views/widgets/images/one_image_picker.dart index daacbddc..44188ca6 100644 --- a/lib/views/widgets/images/one_image_picker.dart +++ b/lib/views/widgets/images/one_image_picker.dart @@ -13,7 +13,7 @@ // final String label; // final bool error; // -// const AOneImagePicker({Key key, this.label, this.error, this.image, this.onPick}) : super(key: key); +// const AOneImagePicker({Key? key, this.label, this.error, this.image, this.onPick}) : super(key: key); // // @override // _AOneImagePickerState createState() => _AOneImagePickerState(); diff --git a/lib/views/widgets/input_widget.dart b/lib/views/widgets/input_widget.dart index 5147bdea..58d12cf9 100644 --- a/lib/views/widgets/input_widget.dart +++ b/lib/views/widgets/input_widget.dart @@ -27,7 +27,7 @@ // this.labelText, // this.hintText, // this.controller, { -// Key key, +// Key? key, // this.isTextIsPassword = false, // this.suffixTap, // this.validator, diff --git a/lib/views/widgets/issues/report_issue_item.dart b/lib/views/widgets/issues/report_issue_item.dart index bbce00ab..893715a0 100644 --- a/lib/views/widgets/issues/report_issue_item.dart +++ b/lib/views/widgets/issues/report_issue_item.dart @@ -6,7 +6,7 @@ class ReportIssueItem extends StatelessWidget { final String issueInfo; final Function(String, bool) onChange; - const ReportIssueItem({Key key, this.isSelected, this.issueInfo, this.onChange}) : super(key: key); + const ReportIssueItem({Key? key, this.isSelected, this.issueInfo, this.onChange}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/views/widgets/land_page/land_page_item.dart b/lib/views/widgets/land_page/land_page_item.dart index b2b59d4d..00baabbb 100644 --- a/lib/views/widgets/land_page/land_page_item.dart +++ b/lib/views/widgets/land_page/land_page_item.dart @@ -13,7 +13,7 @@ // final VoidCallback onPressed; // final String svgPath; // -// const LandPageItem({Key key, this.svgPath, this.text, this.icon, this.onPressed}) : super(key: key); +// const LandPageItem({Key? key, this.svgPath, this.text, this.icon, this.onPressed}) : super(key: key); // // @override // Widget build(BuildContext context) { diff --git a/lib/views/widgets/loaders/app_loading.dart b/lib/views/widgets/loaders/app_loading.dart index 267313c3..9b427a7d 100644 --- a/lib/views/widgets/loaders/app_loading.dart +++ b/lib/views/widgets/loaders/app_loading.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; class ALoading extends StatelessWidget { - const ALoading({Key key}) : super(key: key); + const ALoading({Key? key}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/views/widgets/loaders/failed_loading.dart b/lib/views/widgets/loaders/failed_loading.dart index a73cdb5f..5f1e1a66 100644 --- a/lib/views/widgets/loaders/failed_loading.dart +++ b/lib/views/widgets/loaders/failed_loading.dart @@ -6,7 +6,7 @@ class FailedLoading extends StatelessWidget { final String message; final VoidCallback onReload; - const FailedLoading({Key key, this.message, this.onReload}) : super(key: key); + const FailedLoading({Key? key, this.message, this.onReload}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/views/widgets/loaders/image_loader.dart b/lib/views/widgets/loaders/image_loader.dart index bc4667bb..fc867288 100644 --- a/lib/views/widgets/loaders/image_loader.dart +++ b/lib/views/widgets/loaders/image_loader.dart @@ -9,7 +9,7 @@ class ImageLoader extends StatelessWidget { final double width; final double height; - const ImageLoader({Key key, @required this.url, this.boxFit, this.color, this.alignment, this.width, this.height}) : super(key: key); + const ImageLoader({Key? key, required this.url, this.boxFit, this.color, this.alignment, this.width, this.height}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/views/widgets/loaders/lazy_loading.dart b/lib/views/widgets/loaders/lazy_loading.dart index 04f430c0..9ebebb2d 100644 --- a/lib/views/widgets/loaders/lazy_loading.dart +++ b/lib/views/widgets/loaders/lazy_loading.dart @@ -7,13 +7,13 @@ class LazyLoading extends StatefulWidget { final Widget child; final bool nextPage; final Future Function() onLazyLoad; - final VoidCallback onLoadingEnd; + final VoidCallback? onLoadingEnd; const LazyLoading({ - Key key, + Key? key, this.nextPage = false, - this.child, - this.onLazyLoad, + required this.child, + required this.onLazyLoad, this.onLoadingEnd, }) : super(key: key); @@ -22,8 +22,8 @@ class LazyLoading extends StatefulWidget { } class _LazyLoadingState extends State with TickerProviderStateMixin { - AnimationController _animationController; - Animation _offsetAnimation; + late AnimationController _animationController; + late Animation _offsetAnimation; _scrollListener() async { if (!_animationController.isAnimating && !_animationController.isCompleted && widget.nextPage) { diff --git a/lib/views/widgets/loaders/no_item_found.dart b/lib/views/widgets/loaders/no_item_found.dart index b2d186dd..c1ef410c 100644 --- a/lib/views/widgets/loaders/no_item_found.dart +++ b/lib/views/widgets/loaders/no_item_found.dart @@ -7,7 +7,7 @@ class NoItemFound extends StatelessWidget { final String message; const NoItemFound({ - Key key, + Key? key, this.message, }) : super(key: key); diff --git a/lib/views/widgets/notifications/notification_item.dart b/lib/views/widgets/notifications/notification_item.dart index 02fe4e3b..09955e0c 100644 --- a/lib/views/widgets/notifications/notification_item.dart +++ b/lib/views/widgets/notifications/notification_item.dart @@ -14,7 +14,7 @@ class NotificationItem extends StatelessWidget { final bool isLoading; - const NotificationItem({Key key, this.notification, this.onPressed, this.isLoading = false}) : super(key: key); + const NotificationItem({Key? key, this.notification, this.onPressed, this.isLoading = false}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/views/widgets/parts/auto_complete_parts_field.dart b/lib/views/widgets/parts/auto_complete_parts_field.dart index 7f3c6e75..05c9bde1 100644 --- a/lib/views/widgets/parts/auto_complete_parts_field.dart +++ b/lib/views/widgets/parts/auto_complete_parts_field.dart @@ -19,7 +19,7 @@ class AutoCompletePartsField extends StatefulWidget { final bool clearAfterPick, byName; final Function(SparePartsWorkOrders) onPick; - const AutoCompletePartsField({Key key, this.byName, this.initialValue, this.assetId, this.onPick, this.clearAfterPick = true}) : super(key: key); + const AutoCompletePartsField({Key? key, this.byName, this.initialValue, this.assetId, this.onPick, this.clearAfterPick = true}) : super(key: key); @override _AutoCompletePartsFieldState createState() => _AutoCompletePartsFieldState(); diff --git a/lib/views/widgets/parts/part_item.dart b/lib/views/widgets/parts/part_item.dart index 6f839983..c2a2fcce 100644 --- a/lib/views/widgets/parts/part_item.dart +++ b/lib/views/widgets/parts/part_item.dart @@ -10,7 +10,7 @@ // final Function(SparePartsWorkOrders) onDelete; // final Function(int qty) onEdit; // -// const PartItem({Key key, this.part, this.onEdit, this.onDelete}) : super(key: key); +// const PartItem({Key? key, this.part, this.onEdit, this.onDelete}) : super(key: key); // // @override // _PartItemState createState() => _PartItemState(); diff --git a/lib/views/widgets/pentry/auto_complete_fields/auto_complete_devices_field.dart b/lib/views/widgets/pentry/auto_complete_fields/auto_complete_devices_field.dart index 72ca845a..87fc073a 100644 --- a/lib/views/widgets/pentry/auto_complete_fields/auto_complete_devices_field.dart +++ b/lib/views/widgets/pentry/auto_complete_fields/auto_complete_devices_field.dart @@ -22,7 +22,7 @@ // final int hospitalId; // final Function(Lookup) onPick; // -// const AutoCompleteDeviceNumberField({Key key, this.initialValue, this.onPick, this.hospitalId}) : super(key: key); +// const AutoCompleteDeviceNumberField({Key? key, this.initialValue, this.onPick, this.hospitalId}) : super(key: key); // // @override // State createState() => _AutoCompleteDeviceNumberFieldState(); diff --git a/lib/views/widgets/pentry/calibration_tool_asset_picker.dart b/lib/views/widgets/pentry/calibration_tool_asset_picker.dart index e8b45968..5c0c40b0 100644 --- a/lib/views/widgets/pentry/calibration_tool_asset_picker.dart +++ b/lib/views/widgets/pentry/calibration_tool_asset_picker.dart @@ -22,7 +22,7 @@ class CalibrationToolAssetPicker extends StatefulWidget { final int hospitalId; final Function(Lookup) onPick; - const CalibrationToolAssetPicker({Key key, this.initialValue, this.onPick, this.hospitalId}) : super(key: key); + const CalibrationToolAssetPicker({Key? key, this.initialValue, this.onPick, this.hospitalId}) : super(key: key); @override State createState() => _CalibrationToolAssetPickerState(); diff --git a/lib/views/widgets/pentry/pentry_calibration_tool_form.dart b/lib/views/widgets/pentry/pentry_calibration_tool_form.dart index 4991d2be..825b386d 100644 --- a/lib/views/widgets/pentry/pentry_calibration_tool_form.dart +++ b/lib/views/widgets/pentry/pentry_calibration_tool_form.dart @@ -19,7 +19,7 @@ import 'auto_complete_fields/auto_complete_devices_field.dart'; class PentryCalibrationToolForm extends StatefulWidget { final List models; - const PentryCalibrationToolForm({Key key, this.models}) : super(key: key); + const PentryCalibrationToolForm({Key? key, this.models}) : super(key: key); @override State createState() => _PentryCalibrationToolFormState(); diff --git a/lib/views/widgets/pentry/pentry_pm_kit_form.dart b/lib/views/widgets/pentry/pentry_pm_kit_form.dart index d60b6844..f744a48f 100644 --- a/lib/views/widgets/pentry/pentry_pm_kit_form.dart +++ b/lib/views/widgets/pentry/pentry_pm_kit_form.dart @@ -14,7 +14,7 @@ class PentryPMKitForm extends StatefulWidget { final List models; final num assetId; - const PentryPMKitForm({Key key, this.models, this.assetId}) : super(key: key); + const PentryPMKitForm({Key? key, this.models, this.assetId}) : super(key: key); @override State createState() => _PentryPMKitFormState(); diff --git a/lib/views/widgets/pentry/pentry_ppm_check_list_form.dart b/lib/views/widgets/pentry/pentry_ppm_check_list_form.dart index 42578c84..a9af5ecb 100644 --- a/lib/views/widgets/pentry/pentry_ppm_check_list_form.dart +++ b/lib/views/widgets/pentry/pentry_ppm_check_list_form.dart @@ -13,7 +13,7 @@ import 'package:test_sa/providers/ppm_checklist_status_provider.dart'; class PentryPMChecklistForm extends StatefulWidget { final List models; - const PentryPMChecklistForm({Key key, this.models}) : super(key: key); + const PentryPMChecklistForm({Key? key, this.models}) : super(key: key); @override State createState() => _PentryPMChecklistFormState(); diff --git a/lib/views/widgets/pentry/pentry_tbs_form.dart b/lib/views/widgets/pentry/pentry_tbs_form.dart index 88dc35e4..7b17d292 100644 --- a/lib/views/widgets/pentry/pentry_tbs_form.dart +++ b/lib/views/widgets/pentry/pentry_tbs_form.dart @@ -29,7 +29,7 @@ import '../timer/app_timer.dart'; class PentryTBSForm extends StatefulWidget { final Ppm model; - const PentryTBSForm({Key key, this.model}) : super(key: key); + const PentryTBSForm({Key? key, this.model}) : super(key: key); @override State createState() => _PentryTBSFormState(); diff --git a/lib/views/widgets/ppm/ppm_item.dart b/lib/views/widgets/ppm/ppm_item.dart index 70bf7e35..f5557308 100644 --- a/lib/views/widgets/ppm/ppm_item.dart +++ b/lib/views/widgets/ppm/ppm_item.dart @@ -19,7 +19,7 @@ class PpmItem extends StatelessWidget { final Ppm ppm; final RequestsDetails request; - const PpmItem({Key key, this.ppm, this.request}) : super(key: key); + const PpmItem({Key? key, this.ppm, this.request}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/views/widgets/qr/asset_scan_qr.dart b/lib/views/widgets/qr/asset_scan_qr.dart index 5bcfa519..f0e0235c 100644 --- a/lib/views/widgets/qr/asset_scan_qr.dart +++ b/lib/views/widgets/qr/asset_scan_qr.dart @@ -16,7 +16,7 @@ import '../../pages/device_transfer/search_asset_page.dart'; class AssetScanQr extends StatefulWidget { static const String id = "/asset-scan-qr"; - const AssetScanQr({Key key, this.title}) : super(key: key); + const AssetScanQr({Key? key, this.title}) : super(key: key); final String title; @override @@ -81,9 +81,9 @@ class _AssetScanQrState extends State { if (!_scanDone) { _scanDone = true; final result = await _getDevice(scanData.code, isQr: true); - if(result.isNotEmpty) { + if (result.isNotEmpty) { Navigator.of(context).pop(result[0]); - }else{ + } else { _scanDone = false; } } @@ -97,11 +97,7 @@ class _AssetScanQrState extends State { fit: BoxFit.fitHeight, ), ), - SizedBox( - height: 60.toScreenHeight, - child: CustomAppBar( - title: widget.title, - )), + SizedBox(height: 60.toScreenHeight, child: CustomAppBar(title: widget.title)), ], ), ), diff --git a/lib/views/widgets/qr/scan_qr.dart b/lib/views/widgets/qr/scan_qr.dart index 63c188a2..bcb8ba3b 100644 --- a/lib/views/widgets/qr/scan_qr.dart +++ b/lib/views/widgets/qr/scan_qr.dart @@ -6,7 +6,7 @@ import 'package:qr_code_scanner/qr_code_scanner.dart'; import '../buttons/app_icon_button.dart'; class ScanQr extends StatefulWidget { - const ScanQr({Key key}) : super(key: key); + const ScanQr({Key? key}) : super(key: key); @override _ScanQrState createState() => _ScanQrState(); diff --git a/lib/views/widgets/requests/info_row.dart b/lib/views/widgets/requests/info_row.dart index c934e3be..efd84209 100644 --- a/lib/views/widgets/requests/info_row.dart +++ b/lib/views/widgets/requests/info_row.dart @@ -9,7 +9,7 @@ // final Widget contentWidget; // final Widget infoWidget; // -// const RequestInfoRow({Key key, this.title, this.info, this.content, this.contentWidget, this.infoWidget}) : super(key: key); +// const RequestInfoRow({Key? key, this.title, this.info, this.content, this.contentWidget, this.infoWidget}) : super(key: key); // // @override // Widget build(BuildContext context) { diff --git a/lib/views/widgets/requests/request_status.dart b/lib/views/widgets/requests/request_status.dart index b10bec3e..9816b72b 100644 --- a/lib/views/widgets/requests/request_status.dart +++ b/lib/views/widgets/requests/request_status.dart @@ -3,14 +3,14 @@ import 'package:test_sa/extensions/context_extension.dart'; import 'package:test_sa/extensions/text_extensions.dart'; class StatusLabel extends StatelessWidget { - String label; + String? label; final int id; - final Color backgroundColor; - final Color textColor; + final Color? backgroundColor; + final Color? textColor; final bool isPriority; final double radius; - StatusLabel({Key key, this.id = 0, this.label, this.backgroundColor, this.textColor, this.isPriority = false, this.radius = 4}) : super(key: key); + StatusLabel({Key? key, this.id = 0, this.label, this.backgroundColor, this.textColor, this.isPriority = false, this.radius = 4}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/views/widgets/requests/service_request_item.dart b/lib/views/widgets/requests/service_request_item.dart index 8cef5b6a..d2fe840e 100644 --- a/lib/views/widgets/requests/service_request_item.dart +++ b/lib/views/widgets/requests/service_request_item.dart @@ -14,7 +14,7 @@ class ServiceRequestItem extends StatelessWidget { final ServiceRequest request; final Function(ServiceRequest) onPressed; - const ServiceRequestItem({Key key, this.request, this.onPressed, this.index}) : super(key: key); + const ServiceRequestItem({Key? key, this.request, this.onPressed, this.index}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/views/widgets/requests/service_request_list.dart b/lib/views/widgets/requests/service_request_list.dart index 9827338f..38a83161 100644 --- a/lib/views/widgets/requests/service_request_list.dart +++ b/lib/views/widgets/requests/service_request_list.dart @@ -14,7 +14,7 @@ class ServiceRequestsList extends StatelessWidget { final bool nextPage; final Future Function() onLazyLoad; - const ServiceRequestsList({Key key, this.requests, this.nextPage, this.onLazyLoad}) : super(key: key); + const ServiceRequestsList({Key? key, this.requests, this.nextPage, this.onLazyLoad}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/views/widgets/requests/service_request_update_dialog.dart b/lib/views/widgets/requests/service_request_update_dialog.dart index ee338f8a..4a0f6759 100644 --- a/lib/views/widgets/requests/service_request_update_dialog.dart +++ b/lib/views/widgets/requests/service_request_update_dialog.dart @@ -19,7 +19,7 @@ // final ServiceRequest request; // // const ServiceRequestsUpdateDialog({ -// Key key, +// Key? key, // this.request, // }) : super(key: key); // diff --git a/lib/views/widgets/search/asset_transfer_search_dialog.dart b/lib/views/widgets/search/asset_transfer_search_dialog.dart index 8ee7dd2e..0b9a4312 100644 --- a/lib/views/widgets/search/asset_transfer_search_dialog.dart +++ b/lib/views/widgets/search/asset_transfer_search_dialog.dart @@ -15,7 +15,7 @@ // final bool expandedSearch; // final Function(AssetTransfer) onSearch; // -// const AssetTransferSearchDialog({Key key, this.initialSearchValue, this.expandedSearch, this.onSearch}) : super(key: key); +// const AssetTransferSearchDialog({Key? key, this.initialSearchValue, this.expandedSearch, this.onSearch}) : super(key: key); // // @override // AssetTransferSearchDialogState createState() => AssetTransferSearchDialogState(); diff --git a/lib/views/widgets/search/filter_item.dart b/lib/views/widgets/search/filter_item.dart index 02137aa6..8f5f9c57 100644 --- a/lib/views/widgets/search/filter_item.dart +++ b/lib/views/widgets/search/filter_item.dart @@ -8,7 +8,7 @@ // final Lookup status; // final VoidCallback onSelected; // -// const FilterItem({Key key, this.status, this.isSelected, this.onSelected}) : super(key: key); +// const FilterItem({Key? key, this.status, this.isSelected, this.onSelected}) : super(key: key); // // // // // Color getStatusColor() { diff --git a/lib/views/widgets/search/ppm_search_bar.dart b/lib/views/widgets/search/ppm_search_bar.dart index ade9aa52..cce23311 100644 --- a/lib/views/widgets/search/ppm_search_bar.dart +++ b/lib/views/widgets/search/ppm_search_bar.dart @@ -14,7 +14,7 @@ // final bool expandedSearch; // final Function(PpmSearch) onSearch; // -// const PpmSearchDialog({Key key, this.initialSearchValue, this.expandedSearch, this.onSearch}) : super(key: key); +// const PpmSearchDialog({Key? key, this.initialSearchValue, this.expandedSearch, this.onSearch}) : super(key: key); // // @override // _PpmSearchDialogState createState() => _PpmSearchDialogState(); diff --git a/lib/views/widgets/search/service_request_search_bar.dart b/lib/views/widgets/search/service_request_search_bar.dart index 18a1dec2..1f34b946 100644 --- a/lib/views/widgets/search/service_request_search_bar.dart +++ b/lib/views/widgets/search/service_request_search_bar.dart @@ -23,7 +23,7 @@ // final bool expandedSearch; // final Function(ServiceRequestSearch) onSearch; // -// const ServiceRequestsSearchDialog({Key key, this.initialSearchValue, this.expandedSearch, this.onSearch}) : super(key: key); +// const ServiceRequestsSearchDialog({Key? key, this.initialSearchValue, this.expandedSearch, this.onSearch}) : super(key: key); // // @override // _ServiceRequestsSearchDialogState createState() => _ServiceRequestsSearchDialogState(); diff --git a/lib/views/widgets/sound/TextSpeechRecordWidget.dart b/lib/views/widgets/sound/TextSpeechRecordWidget.dart index 27d553bd..8a749ae2 100644 --- a/lib/views/widgets/sound/TextSpeechRecordWidget.dart +++ b/lib/views/widgets/sound/TextSpeechRecordWidget.dart @@ -7,7 +7,7 @@ import 'package:fluttertoast/fluttertoast.dart'; import 'package:path_provider/path_provider.dart'; import 'package:permission_handler/permission_handler.dart'; import 'package:provider/provider.dart'; -import 'package:record_mp3/record_mp3.dart'; +import 'package:record_mp3_plus/record_mp3_plus.dart'; import 'package:rive/rive.dart'; import 'package:speech_to_text/speech_recognition_error.dart'; import 'package:speech_to_text/speech_recognition_result.dart'; @@ -23,13 +23,13 @@ import '../../../new_views/app_style/app_color.dart'; import '../../../new_views/common_widgets/app_text_form_field.dart'; class TextSpeechRecordWidget extends StatefulWidget { - final Function(String) onRecord; - final Function(String) onStop; + final Function(String?) onRecord; + final Function(String)? onStop; final bool enabled; final Function(String) onMessageChange; final String initialMessage; - const TextSpeechRecordWidget({Key key, @required this.onRecord, this.onStop, this.enabled = true, this.onMessageChange, this.initialMessage}) : super(key: key); + const TextSpeechRecordWidget({Key? key, required this.onRecord, this.onStop, this.enabled = true,required this.onMessageChange,required this.initialMessage}) : super(key: key); @override State createState() => _RecordSoundState(); @@ -41,11 +41,11 @@ class _RecordSoundState extends State { bool _recorderIsOpened = false; bool _recording = false; bool _played = false; - String _record; - Artboard _rive; - Timer _timer; - TextEditingController _timeController; - TextEditingController _commentController; + String? _record; + Artboard? _rive; + Timer? _timer; + late TextEditingController _timeController; + late TextEditingController _commentController; bool _speechEnabled = false; FocusNode node = FocusNode(); @@ -67,7 +67,7 @@ class _RecordSoundState extends State { ); } - SettingProvider _settingProvider; + late SettingProvider _settingProvider; @override void initState() { @@ -114,7 +114,7 @@ class _RecordSoundState extends State { super.dispose(); } - String recordingFileDirectory; + String? recordingFileDirectory; _startRecording() async { PermissionStatus status = await Permission.microphone.request(); @@ -127,10 +127,10 @@ class _RecordSoundState extends State { } _timer = Timer.periodic(const Duration(seconds: 1), (timer) { setState(() { - String duration = Duration(seconds: timer?.tick).toString(); + String duration = Duration(seconds: timer.tick).toString(); duration = duration.substring(duration.indexOf(":") + 1, duration.indexOf(".")); - String recordTime = ((timer?.tick ?? 0) / 60)?.toStringAsFixed(2)?.replaceFirst(".", ":"); + String recordTime = ((timer.tick ?? 0) / 60).toStringAsFixed(2).replaceFirst(".", ":"); // print("recordTime:$recordTime"); if (recordTime.length == 4 || recordTime.length == 7) { recordTime = "0$recordTime"; @@ -138,14 +138,14 @@ class _RecordSoundState extends State { _timeController.text = duration; }); }); - _rive.addController(SimpleAnimation('recording')); + _rive?.addController(SimpleAnimation('recording')); if (!_recorderIsOpened) { // await _myRecorder.openRecorder(); _recorderIsOpened = true; } final Directory tempDir = await getTemporaryDirectory(); recordingFileDirectory = "${tempDir.path}/record_${DateTime.now().millisecondsSinceEpoch}.mp3"; - RecordMp3.instance.start(recordingFileDirectory, (type) { + RecordMp3.instance.start(recordingFileDirectory!, (type) { // record fail callback }); @@ -161,13 +161,13 @@ class _RecordSoundState extends State { return; } if (_timer?.isActive ?? false) { - _timer.cancel(); + _timer?.cancel(); } RecordMp3.instance.stop(); //String path = (await _myRecorder.stopRecorder()).toString(); _record = recordingFileDirectory; - widget.onRecord(recordingFileDirectory); + widget.onRecord(recordingFileDirectory!); _recording = false; setState(() {}); } @@ -199,7 +199,7 @@ class _RecordSoundState extends State { RecordMp3.instance.stop(); // String path = await _myRecorder.stopRecorder(); // _myRecorder.deleteRecord(fileName: path); - _rive.addController(SimpleAnimation('delete')); + _rive?.addController(SimpleAnimation('delete')); // rebuild(); _recording = false; @@ -270,7 +270,7 @@ class _RecordSoundState extends State { ]; }, )) - .paddingOnly(end: 16,top: 16), + .paddingOnly(end: 16, top: 16), ], if (_recording) @@ -283,7 +283,7 @@ class _RecordSoundState extends State { labelText: context.translation.recordVoice, textInputType: TextInputType.multiline, alignLabelWithHint: true, - initialValue: (_timeController?.text?.isEmpty ?? true) ? "00:00" : _timeController?.text, + initialValue: (_timeController.text.isEmpty) ? "00:00" : _timeController.text, // suffixIcon: // (_recording ? "record".toLottieAsset(height: 24) : (_record != null ? "trash" : "mic").toSvgAsset(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20, height: 24)) // .paddingOnly(end: 16), @@ -327,7 +327,7 @@ class _RecordSoundState extends State { child: (_recording ? "record".toLottieAsset(height: 24) : (_record != null ? "trash" : "mic").toSvgAsset(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20, height: 24, width: 24)), - ).paddingOnly(end: 16,top: 16).onPress(() { + ).paddingOnly(end: 16, top: 16).onPress(() { if (_recording) { _stopRecording(); } else if (_record != null) { @@ -344,7 +344,7 @@ class _RecordSoundState extends State { if (_record != null) ...[ //8.height, const Divider().defaultStyle(context), - ASoundPlayer(audio: _record).paddingOnly(top: 8, bottom: 16, start: 16, end: 16), + ASoundPlayer(audio: _record!).paddingOnly(top: 8, bottom: 16, start: 16, end: 16), ] ], ).toShadowContainer(context, padding: 0); diff --git a/lib/views/widgets/sound/sound_player.dart b/lib/views/widgets/sound/sound_player.dart index 22887708..7555f980 100644 --- a/lib/views/widgets/sound/sound_player.dart +++ b/lib/views/widgets/sound/sound_player.dart @@ -8,7 +8,7 @@ import 'package:test_sa/new_views/app_style/app_text_style.dart'; class ASoundPlayer extends StatefulWidget { final String audio; - const ASoundPlayer({Key key, this.audio}) : super(key: key); + const ASoundPlayer({Key? key, required this.audio}) : super(key: key); @override _ASoundPlayerState createState() => _ASoundPlayerState(); @@ -17,12 +17,12 @@ class ASoundPlayer extends StatefulWidget { class _ASoundPlayerState extends State { //FlutterSoundPlayer _myPlayer = FlutterSoundPlayer(); bool _sliderMoving = false; - Duration _audioTime; - Duration _audioPosition; - String _audio; + Duration? _audioTime; + Duration? _audioPosition; + late String _audio; bool _isLocalFile = false; bool _failedToLoad = false; - AudioPlayer _audioPlayer; + late AudioPlayer _audioPlayer; Widget audioPlayerButton(IconData icon, VoidCallback onpress) { return Container( @@ -199,7 +199,7 @@ class _ASoundPlayerState extends State { ).paddingOnly(start: 8, end: 8).expanded, _failedToLoad ? Text("Failed to load", style: AppTextStyle.tiny.copyWith(color: context.isDark ? AppColor.red50 : AppColor.red60)) - : Text("${format(_audioPosition)}/${format(_audioTime)}", style: AppTextStyle.tiny.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50)), + : Text("${format(_audioPosition!)}/${format(_audioTime!)}", style: AppTextStyle.tiny.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50)), ], ), ], diff --git a/lib/views/widgets/speech_to_text/speech_to_text.dart b/lib/views/widgets/speech_to_text/speech_to_text.dart index e221f7ba..4a9e3a3f 100644 --- a/lib/views/widgets/speech_to_text/speech_to_text.dart +++ b/lib/views/widgets/speech_to_text/speech_to_text.dart @@ -1,156 +1,156 @@ -import 'package:flutter/material.dart'; -import 'package:fluttertoast/fluttertoast.dart'; -import 'package:provider/provider.dart'; -import 'package:speech_to_text/speech_recognition_error.dart'; -import 'package:speech_to_text/speech_recognition_result.dart'; -import 'package:speech_to_text/speech_to_text.dart'; -import 'package:test_sa/controllers/providers/settings/setting_provider.dart'; -import 'package:test_sa/extensions/context_extension.dart'; -import 'package:test_sa/new_views/app_style/app_color.dart'; -import 'package:test_sa/new_views/app_style/app_text_style.dart'; -import 'package:test_sa/views/app_style/sizing.dart'; -import 'package:test_sa/views/widgets/buttons/app_icon_button2.dart'; -import 'package:test_sa/views/widgets/titles/app_sub_title.dart'; - -class SpeechToTextButton extends StatefulWidget { - final TextEditingController controller; - final bool mini; - final bool enabled; - - const SpeechToTextButton({Key key, this.controller, this.mini = false, this.enabled = true}) : super(key: key); - - @override - _SpeechToTextButtonState createState() => _SpeechToTextButtonState(); -} - -class _SpeechToTextButtonState extends State { - bool _speechEnabled = false; - SettingProvider _settingProvider; - final SpeechToText _speechToText = SpeechToText(); - - /// This has to happen only once per app - void _initSpeech() async { - _speechEnabled = await _speechToText.initialize( - onError: (SpeechRecognitionError error) async { - Fluttertoast.showToast(msg: "failed to convert text to speech"); - setState(() {}); - }, - ); - } - - /// Each time to start a speech recognition session - void _startListening() async { - _speechEnabled = _speechToText.isAvailable; - if (_speechToText.isListening) { - Fluttertoast.showToast(msg: "Currently in use"); - return; - } - if (!_speechEnabled) return; - await _speechToText.listen( - onResult: (SpeechRecognitionResult result) { - widget.controller.text = result.recognizedWords; - setState(() {}); - }, - localeId: _settingProvider.speechToText); - setState(() {}); - } - - /// Manually stop the active speech recognition session - /// Note that there are also timeouts that each platform enforces - /// and the SpeechToText plugin supports setting timeouts on the - /// listen method. - void _stopListening() async { - await _speechToText.stop(); - setState(() {}); - } - - @override - void initState() { - _initSpeech(); - widget.controller.addListener(() { - setState(() {}); - }); - super.initState(); - } - - @override - void setState(VoidCallback fn) { - if (!mounted) return; - super.setState(fn); - } - - @override - Widget build(BuildContext context) { - _settingProvider = Provider.of(context); - return Container( - padding: const EdgeInsets.only(left: 12, right: 12), - decoration: BoxDecoration( - color: context.isDark && (widget.enabled == false) - ? AppColor.neutral50 - : (widget.enabled == false) - ? AppColor.neutral40 - : AppColor.background(context), - borderRadius: BorderRadius.circular(10), - boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.05), blurRadius: 10)], - ), - child: Row( - children: [ - widget.mini - ? const SizedBox.shrink() - : Text( - "Speech To Text", - style: Theme.of(context).textTheme.bodyLarge, - ), - widget.controller.text.isNotEmpty && widget.enabled - ? AIconButton2( - iconData: Icons.delete, - color: context.isDark ? Colors.white : Colors.black87, - onPressed: () { - widget.controller.clear(); - setState(() {}); - }, - ) - : const SizedBox.shrink(), - const Spacer(), - TextButton( - onPressed: widget.enabled - ? () { - if (_speechToText.isListening) return; - - if (_settingProvider.speechToText == "ar") { - _settingProvider.setSpeechToText("en"); - } else { - _settingProvider.setSpeechToText("ar"); - } - } - : null, - child: Text(_settingProvider.speechToText)), - GestureDetector( - child: _speechToText.isListening - ? const Icon( - Icons.fiber_manual_record, - color: Colors.red, - ) - : Icon( - Icons.mic, - color: Theme.of(context).colorScheme.primary, - ), - onTap: widget.enabled - ? () async { - if (!_speechEnabled) { - Fluttertoast.showToast(msg: "microphone not available"); - return; - } - if (_speechToText.isListening) { - _stopListening(); - } else { - _startListening(); - } - } - : null, - ), - ], - ), - ); - } -} +// import 'package:flutter/material.dart'; +// import 'package:fluttertoast/fluttertoast.dart'; +// import 'package:provider/provider.dart'; +// import 'package:speech_to_text/speech_recognition_error.dart'; +// import 'package:speech_to_text/speech_recognition_result.dart'; +// import 'package:speech_to_text/speech_to_text.dart'; +// import 'package:test_sa/controllers/providers/settings/setting_provider.dart'; +// import 'package:test_sa/extensions/context_extension.dart'; +// import 'package:test_sa/new_views/app_style/app_color.dart'; +// import 'package:test_sa/new_views/app_style/app_text_style.dart'; +// import 'package:test_sa/views/app_style/sizing.dart'; +// import 'package:test_sa/views/widgets/buttons/app_icon_button2.dart'; +// import 'package:test_sa/views/widgets/titles/app_sub_title.dart'; +// +// class SpeechToTextButton extends StatefulWidget { +// final TextEditingController controller; +// final bool mini; +// final bool enabled; +// +// const SpeechToTextButton({Key? key, this.controller, this.mini = false, this.enabled = true}) : super(key: key); +// +// @override +// _SpeechToTextButtonState createState() => _SpeechToTextButtonState(); +// } +// +// class _SpeechToTextButtonState extends State { +// bool _speechEnabled = false; +// SettingProvider _settingProvider; +// final SpeechToText _speechToText = SpeechToText(); +// +// /// This has to happen only once per app +// void _initSpeech() async { +// _speechEnabled = await _speechToText.initialize( +// onError: (SpeechRecognitionError error) async { +// Fluttertoast.showToast(msg: "failed to convert text to speech"); +// setState(() {}); +// }, +// ); +// } +// +// /// Each time to start a speech recognition session +// void _startListening() async { +// _speechEnabled = _speechToText.isAvailable; +// if (_speechToText.isListening) { +// Fluttertoast.showToast(msg: "Currently in use"); +// return; +// } +// if (!_speechEnabled) return; +// await _speechToText.listen( +// onResult: (SpeechRecognitionResult result) { +// widget.controller.text = result.recognizedWords; +// setState(() {}); +// }, +// localeId: _settingProvider.speechToText); +// setState(() {}); +// } +// +// /// Manually stop the active speech recognition session +// /// Note that there are also timeouts that each platform enforces +// /// and the SpeechToText plugin supports setting timeouts on the +// /// listen method. +// void _stopListening() async { +// await _speechToText.stop(); +// setState(() {}); +// } +// +// @override +// void initState() { +// _initSpeech(); +// widget.controller.addListener(() { +// setState(() {}); +// }); +// super.initState(); +// } +// +// @override +// void setState(VoidCallback fn) { +// if (!mounted) return; +// super.setState(fn); +// } +// +// @override +// Widget build(BuildContext context) { +// _settingProvider = Provider.of(context); +// return Container( +// padding: const EdgeInsets.only(left: 12, right: 12), +// decoration: BoxDecoration( +// color: context.isDark && (widget.enabled == false) +// ? AppColor.neutral50 +// : (widget.enabled == false) +// ? AppColor.neutral40 +// : AppColor.background(context), +// borderRadius: BorderRadius.circular(10), +// boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.05), blurRadius: 10)], +// ), +// child: Row( +// children: [ +// widget.mini +// ? const SizedBox.shrink() +// : Text( +// "Speech To Text", +// style: Theme.of(context).textTheme.bodyLarge, +// ), +// widget.controller.text.isNotEmpty && widget.enabled +// ? AIconButton2( +// iconData: Icons.delete, +// color: context.isDark ? Colors.white : Colors.black87, +// onPressed: () { +// widget.controller.clear(); +// setState(() {}); +// }, +// ) +// : const SizedBox.shrink(), +// const Spacer(), +// TextButton( +// onPressed: widget.enabled +// ? () { +// if (_speechToText.isListening) return; +// +// if (_settingProvider.speechToText == "ar") { +// _settingProvider.setSpeechToText("en"); +// } else { +// _settingProvider.setSpeechToText("ar"); +// } +// } +// : null, +// child: Text(_settingProvider.speechToText)), +// GestureDetector( +// child: _speechToText.isListening +// ? const Icon( +// Icons.fiber_manual_record, +// color: Colors.red, +// ) +// : Icon( +// Icons.mic, +// color: Theme.of(context).colorScheme.primary, +// ), +// onTap: widget.enabled +// ? () async { +// if (!_speechEnabled) { +// Fluttertoast.showToast(msg: "microphone not available"); +// return; +// } +// if (_speechToText.isListening) { +// _stopListening(); +// } else { +// _startListening(); +// } +// } +// : null, +// ), +// ], +// ), +// ); +// } +// } diff --git a/lib/views/widgets/status/asset_status.dart b/lib/views/widgets/status/asset_status.dart index 0eb105e9..e3e03da9 100644 --- a/lib/views/widgets/status/asset_status.dart +++ b/lib/views/widgets/status/asset_status.dart @@ -13,7 +13,7 @@ // final Lookup initialValue; // final bool enabled; // -// const AssetStatusMenu({Key key, this.enabled = true, this.onSelect, this.initialValue}) : super(key: key); +// const AssetStatusMenu({Key? key, this.enabled = true, this.onSelect, this.initialValue}) : super(key: key); // // @override // Widget build(BuildContext context) { diff --git a/lib/views/widgets/status/employee/assigned_to_menu.dart b/lib/views/widgets/status/employee/assigned_to_menu.dart index 4ed9ad13..e99dd822 100644 --- a/lib/views/widgets/status/employee/assigned_to_menu.dart +++ b/lib/views/widgets/status/employee/assigned_to_menu.dart @@ -12,7 +12,7 @@ // final Function(Lookup) onSelect; // final Lookup initialValue; // -// const AssignedToMenu({Key key, this.onSelect, this.initialValue}) : super(key: key); +// const AssignedToMenu({Key? key, this.onSelect, this.initialValue}) : super(key: key); // // @override // Widget build(BuildContext context) { diff --git a/lib/views/widgets/status/employee/engineers_menu.dart b/lib/views/widgets/status/employee/engineers_menu.dart index c831249e..a9c88303 100644 --- a/lib/views/widgets/status/employee/engineers_menu.dart +++ b/lib/views/widgets/status/employee/engineers_menu.dart @@ -12,7 +12,7 @@ // final Function(Employee) onSelect; // final Employee initialValue; // -// const EngineersMenu({Key key, this.onSelect, this.initialValue}) : super(key: key); +// const EngineersMenu({Key? key, this.onSelect, this.initialValue}) : super(key: key); // // @override // Widget build(BuildContext context) { diff --git a/lib/views/widgets/status/employee/single_type_menu.dart b/lib/views/widgets/status/employee/single_type_menu.dart index 6b026f38..ef99537d 100644 --- a/lib/views/widgets/status/employee/single_type_menu.dart +++ b/lib/views/widgets/status/employee/single_type_menu.dart @@ -8,7 +8,7 @@ // final Employee initialStatus; // final Function(Employee) onSelect; // -// const SingleEngineerMenu({Key key, this.engineers, this.onSelect, this.initialStatus}) : super(key: key); +// const SingleEngineerMenu({Key? key, this.engineers, this.onSelect, this.initialStatus}) : super(key: key); // // @override // _SingleEngineerMenuState createState() => _SingleEngineerMenuState(); diff --git a/lib/views/widgets/status/gas_refill/gas_cylinder_size.dart b/lib/views/widgets/status/gas_refill/gas_cylinder_size.dart index 8915a29a..0d2345c1 100644 --- a/lib/views/widgets/status/gas_refill/gas_cylinder_size.dart +++ b/lib/views/widgets/status/gas_refill/gas_cylinder_size.dart @@ -12,7 +12,7 @@ // final Function(Lookup) onSelect; // final Lookup initialValue; // -// const GasCylinderSizeMenu({Key key, this.onSelect, this.initialValue}) : super(key: key); +// const GasCylinderSizeMenu({Key? key, this.onSelect, this.initialValue}) : super(key: key); // // @override // Widget build(BuildContext context) { diff --git a/lib/views/widgets/status/gas_refill/gas_cylinder_type.dart b/lib/views/widgets/status/gas_refill/gas_cylinder_type.dart index f979a637..aba74e37 100644 --- a/lib/views/widgets/status/gas_refill/gas_cylinder_type.dart +++ b/lib/views/widgets/status/gas_refill/gas_cylinder_type.dart @@ -12,7 +12,7 @@ // final Function(Lookup) onSelect; // final Lookup initialValue; // -// const GasCylinderTypesMenu({Key key, this.onSelect, this.initialValue}) : super(key: key); +// const GasCylinderTypesMenu({Key? key, this.onSelect, this.initialValue}) : super(key: key); // // @override // Widget build(BuildContext context) { diff --git a/lib/views/widgets/status/gas_refill/gas_status.dart b/lib/views/widgets/status/gas_refill/gas_status.dart index d960f3aa..86383206 100644 --- a/lib/views/widgets/status/gas_refill/gas_status.dart +++ b/lib/views/widgets/status/gas_refill/gas_status.dart @@ -13,7 +13,7 @@ // final Lookup initialValue; // final bool enabled; // -// const GasStatusMenu({Key key, this.enabled = true, this.onSelect, this.initialValue}) : super(key: key); +// const GasStatusMenu({Key? key, this.enabled = true, this.onSelect, this.initialValue}) : super(key: key); // // @override // Widget build(BuildContext context) { diff --git a/lib/views/widgets/status/gas_refill/gas_type.dart b/lib/views/widgets/status/gas_refill/gas_type.dart index e790fd29..0c48adca 100644 --- a/lib/views/widgets/status/gas_refill/gas_type.dart +++ b/lib/views/widgets/status/gas_refill/gas_type.dart @@ -12,7 +12,7 @@ // final Function(Lookup) onSelect; // final Lookup initialValue; // -// const GasTypeMenu({Key key, this.onSelect, this.initialValue}) : super(key: key); +// const GasTypeMenu({Key? key, this.onSelect, this.initialValue}) : super(key: key); // // @override // Widget build(BuildContext context) { diff --git a/lib/views/widgets/status/multi_status_menu.dart b/lib/views/widgets/status/multi_status_menu.dart index 66c901cd..47bd4979 100644 --- a/lib/views/widgets/status/multi_status_menu.dart +++ b/lib/views/widgets/status/multi_status_menu.dart @@ -9,7 +9,7 @@ // final List initialSelectedStatus; // final Function(List) onSelect; // -// const MultiStatusMenu({Key key, this.statuses, this.onSelect, this.initialSelectedStatus}) : super(key: key); +// const MultiStatusMenu({Key? key, this.statuses, this.onSelect, this.initialSelectedStatus}) : super(key: key); // // @override // _MultiStatusMenuState createState() => _MultiStatusMenuState(); diff --git a/lib/views/widgets/status/pentry/pentry_status_mune.dart b/lib/views/widgets/status/pentry/pentry_status_mune.dart index 945be4b5..adae0321 100644 --- a/lib/views/widgets/status/pentry/pentry_status_mune.dart +++ b/lib/views/widgets/status/pentry/pentry_status_mune.dart @@ -12,7 +12,7 @@ // final Function(Lookup) onSelect; // final Lookup initialValue; // -// const PentryStatusMenu({Key key, this.onSelect, this.initialValue}) : super(key: key); +// const PentryStatusMenu({Key? key, this.onSelect, this.initialValue}) : super(key: key); // // @override // Widget build(BuildContext context) { diff --git a/lib/views/widgets/status/pentry/pentry_task_status_mune.dart b/lib/views/widgets/status/pentry/pentry_task_status_mune.dart index 530c426f..ba87dcf0 100644 --- a/lib/views/widgets/status/pentry/pentry_task_status_mune.dart +++ b/lib/views/widgets/status/pentry/pentry_task_status_mune.dart @@ -12,7 +12,7 @@ // final Function(Lookup) onSelect; // final Lookup initialValue; // -// const PentryTaskStatusMenu({Key key, this.onSelect, this.initialValue}) : super(key: key); +// const PentryTaskStatusMenu({Key? key, this.onSelect, this.initialValue}) : super(key: key); // // @override // Widget build(BuildContext context) { diff --git a/lib/views/widgets/status/pentry/pentry_visit_status_mune.dart b/lib/views/widgets/status/pentry/pentry_visit_status_mune.dart index 2f9b596f..95dee9fa 100644 --- a/lib/views/widgets/status/pentry/pentry_visit_status_mune.dart +++ b/lib/views/widgets/status/pentry/pentry_visit_status_mune.dart @@ -12,7 +12,7 @@ // final Function(Lookup) onSelect; // final Lookup initialValue; // -// const PentryVisitsStatusMenu({Key key, this.onSelect, this.initialValue}) : super(key: key); +// const PentryVisitsStatusMenu({Key? key, this.onSelect, this.initialValue}) : super(key: key); // // @override // Widget build(BuildContext context) { diff --git a/lib/views/widgets/status/report/fault_desc_menu.dart b/lib/views/widgets/status/report/fault_desc_menu.dart index 776e63c1..06d626dc 100644 --- a/lib/views/widgets/status/report/fault_desc_menu.dart +++ b/lib/views/widgets/status/report/fault_desc_menu.dart @@ -8,7 +8,7 @@ // final FaultDescription initialStatus; // final Function(FaultDescription) onSelect; // -// const FaultDescriptionMenu({Key key, this.statuses, this.onSelect, this.initialStatus}) : super(key: key); +// const FaultDescriptionMenu({Key? key, this.statuses, this.onSelect, this.initialStatus}) : super(key: key); // // @override // _SingleStatusMenuState createState() => _SingleStatusMenuState(); diff --git a/lib/views/widgets/status/report/service_report_all_users.dart b/lib/views/widgets/status/report/service_report_all_users.dart index 1471c3ab..f010a9ae 100644 --- a/lib/views/widgets/status/report/service_report_all_users.dart +++ b/lib/views/widgets/status/report/service_report_all_users.dart @@ -10,7 +10,7 @@ // final Function(Employee) onSelect; // final Employee initialValue; // -// const ServiceReportAllUsers({Key key, @required this.onSelect, this.initialValue}) : super(key: key); +// const ServiceReportAllUsers({Key? key, required this.onSelect, this.initialValue}) : super(key: key); // // @override // Widget build(BuildContext context) { diff --git a/lib/views/widgets/status/report/service_report_assistant_employee_menu.dart b/lib/views/widgets/status/report/service_report_assistant_employee_menu.dart index 46fa6714..4a4063c5 100644 --- a/lib/views/widgets/status/report/service_report_assistant_employee_menu.dart +++ b/lib/views/widgets/status/report/service_report_assistant_employee_menu.dart @@ -54,7 +54,7 @@ class ServiceReportAssistantEmployeeMenu extends StatelessWidget { // final num assetId; // final bool enabled; // -// const ServiceReportAssistantEmployeeMenu({Key key, this.enabled = true, @required this.onSelect, @required this.assetId, this.title, this.initialValue}) : super(key: key); +// const ServiceReportAssistantEmployeeMenu({Key? key, this.enabled = true, required this.onSelect, required this.assetId, this.title, this.initialValue}) : super(key: key); // // @override // State createState() => _ServiceReportAssistantEmployeeMenuState(); diff --git a/lib/views/widgets/status/report/service_report_equipment_status.dart b/lib/views/widgets/status/report/service_report_equipment_status.dart index 835ec65a..3b536189 100644 --- a/lib/views/widgets/status/report/service_report_equipment_status.dart +++ b/lib/views/widgets/status/report/service_report_equipment_status.dart @@ -18,7 +18,7 @@ // final ServiceReport report; // final ServiceRequest request; // -// const ServiceReportEquipmentStatusMenu({Key key, this.onSelect, this.report, this.request}) : super(key: key); +// const ServiceReportEquipmentStatusMenu({Key? key, this.onSelect, this.report, this.request}) : super(key: key); // // @override // State createState() => _ServiceReportEquipmentStatusMenuState(); diff --git a/lib/views/widgets/status/report/service_report_fault_description.dart b/lib/views/widgets/status/report/service_report_fault_description.dart index c54dea9c..15bdfed8 100644 --- a/lib/views/widgets/status/report/service_report_fault_description.dart +++ b/lib/views/widgets/status/report/service_report_fault_description.dart @@ -11,7 +11,7 @@ import 'package:test_sa/views/widgets/loaders/loading_manager.dart'; class ServiceReportFaultDescription extends StatefulWidget { final String? requestId; // Now nullable - final Function(FaultDescription)? onSelect; // Now nullable + final Function(FaultDescription?)? onSelect; // Now nullable final FaultDescription? initialValue; // Now nullable const ServiceReportFaultDescription({Key? key, this.requestId, this.onSelect, this.initialValue}) : super(key: key); diff --git a/lib/views/widgets/status/report/service_report_last_call.dart b/lib/views/widgets/status/report/service_report_last_call.dart index 6b478e41..22f68e36 100644 --- a/lib/views/widgets/status/report/service_report_last_call.dart +++ b/lib/views/widgets/status/report/service_report_last_call.dart @@ -10,40 +10,38 @@ import 'package:test_sa/views/widgets/loaders/loading_manager.dart'; import '../../../../providers/loading_list_notifier.dart'; class ServiceReportLastCallsMenu extends StatelessWidget { - final Function(Lookup) onSelect; + final Function(Lookup?) onSelect; // Accepts nullable Lookup final ServiceReport report; - final String title; - final String parentId; + final String? title; // Nullable title + final String? parentId; // Nullable parentId - const ServiceReportLastCallsMenu({Key key, @required this.onSelect, @required this.report, this.parentId, this.title}) : super(key: key); + const ServiceReportLastCallsMenu({ + Key? key, + required this.onSelect, + required this.report, + this.parentId, + this.title, + }) : super(key: key); @override Widget build(BuildContext context) { - ServiceReportLastCallsProvider menuProvider = Provider.of(context); + final menuProvider = Provider.of(context); return LoadingManager( isLoading: menuProvider.isLoading, isFailedLoading: menuProvider.calls == null, stateCode: menuProvider.stateCode, onRefresh: () async { - await menuProvider.getCalls( - typeName: report.assetType?.name, - id: report.id, - parentId: parentId, - ); + await menuProvider.getCalls(typeName: report.assetType?.name, id: report.id!.toInt(), parentId: parentId); }, child: SingleItemDropDownMenu( context: context, - title: context.translation.callLastSituation, - staticData: menuProvider.calls, - initialValue: report?.calllastSituation, + title: title ?? context.translation.callLastSituation, + // Default title if null + staticData: menuProvider.calls ?? [], + // Empty list if calls is null + initialValue: report.calllastSituation, onSelect: onSelect, ), - // child: SingleStatusMenu( - // title: title, - // initialStatus: report?.calllastSituation, - // statuses: menuProvider.calls, - // onSelect: onSelect, - // ), ); } } diff --git a/lib/views/widgets/status/report/service_report_maintenance_situation.dart b/lib/views/widgets/status/report/service_report_maintenance_situation.dart index be65655d..20e52f89 100644 --- a/lib/views/widgets/status/report/service_report_maintenance_situation.dart +++ b/lib/views/widgets/status/report/service_report_maintenance_situation.dart @@ -12,10 +12,10 @@ // final String woId; // // const ServiceReportMaintenanceSituation({ -// Key key, -// @required this.onSelect, -// @required this.initialValue, -// @required this.woId, +// Key? key, +// required this.onSelect, +// required this.initialValue, +// required this.woId, // }) : super(key: key); // // @override diff --git a/lib/views/widgets/status/report/service_report_reasons.dart b/lib/views/widgets/status/report/service_report_reasons.dart index 8ab6359e..0a18b3bf 100644 --- a/lib/views/widgets/status/report/service_report_reasons.dart +++ b/lib/views/widgets/status/report/service_report_reasons.dart @@ -12,7 +12,7 @@ // final Lookup initialValue; // final Function(Lookup) onSelect; // -// const ServiceReportReasonsMenu({Key key, this.onSelect, this.initialValue}) : super(key: key); +// const ServiceReportReasonsMenu({Key? key, this.onSelect, this.initialValue}) : super(key: key); // // @override // Widget build(BuildContext context) { diff --git a/lib/views/widgets/status/report/service_report_repair_location.dart b/lib/views/widgets/status/report/service_report_repair_location.dart index 83f84e14..7ed6d131 100644 --- a/lib/views/widgets/status/report/service_report_repair_location.dart +++ b/lib/views/widgets/status/report/service_report_repair_location.dart @@ -8,33 +8,30 @@ import 'package:test_sa/views/widgets/loaders/loading_manager.dart'; import 'package:test_sa/views/widgets/status/single_status_menu.dart'; class ServiceReportRepairLocation extends StatelessWidget { - final String label; - final Lookup initialValue; - final Function(Lookup) onSelect; + final String? label; // Nullable + final Lookup? initialValue; // Nullable + final Function(Lookup?)? onSelect; // Nullable function, accepts nullable Lookup - const ServiceReportRepairLocation({Key key, this.label, this.onSelect, this.initialValue}) : super(key: key); + const ServiceReportRepairLocation({Key? key, this.label, this.onSelect, this.initialValue}) : super(key: key); @override Widget build(BuildContext context) { - SettingProvider _settingProvider = Provider.of(context); - UserProvider _userProvider = Provider.of(context); - ServiceReportRepairLocationProvider _menuProvider = Provider.of(context); + final settingProvider = Provider.of(context); + final userProvider = Provider.of(context); + final menuProvider = Provider.of(context); return LoadingManager( - isLoading: _menuProvider.isLoading, - isFailedLoading: _menuProvider.reasons == null, - stateCode: _menuProvider.stateCode, + isLoading: menuProvider.isLoading, + isFailedLoading: menuProvider.reasons == null, + stateCode: menuProvider.stateCode, onRefresh: () async { - _menuProvider.reset(); - await _menuProvider.getTypes( - user: _userProvider.user, - host: _settingProvider.host, - ); + menuProvider.reset(); + await menuProvider.getTypes(); }, child: SingleStatusMenu( title: label, initialStatus: initialValue, - statuses: _menuProvider.reasons, + statuses: menuProvider.reasons, onSelect: onSelect, )); } -} +} \ No newline at end of file diff --git a/lib/views/widgets/status/report/service_report_status.dart b/lib/views/widgets/status/report/service_report_status.dart index dee29df1..2344c7e4 100644 --- a/lib/views/widgets/status/report/service_report_status.dart +++ b/lib/views/widgets/status/report/service_report_status.dart @@ -18,7 +18,7 @@ // final ServiceReport report; // final ServiceRequest request; // -// const ServiceReportStatusMenu({Key key, this.onSelect, this.report, this.request}) : super(key: key); +// const ServiceReportStatusMenu({Key? key, this.onSelect, this.report, this.request}) : super(key: key); // // @override // State createState() => _ServiceReportStatusMenuState(); diff --git a/lib/views/widgets/status/report/service_report_type.dart b/lib/views/widgets/status/report/service_report_type.dart index 53fd6ea6..884a24e8 100644 --- a/lib/views/widgets/status/report/service_report_type.dart +++ b/lib/views/widgets/status/report/service_report_type.dart @@ -12,7 +12,7 @@ // final Function(Lookup) onSelect; // final Lookup initialValue; // -// const ServiceReportTypeMenu({Key key, this.onSelect, this.initialValue}) : super(key: key); +// const ServiceReportTypeMenu({Key? key, this.onSelect, this.initialValue}) : super(key: key); // // @override // Widget build(BuildContext context) { diff --git a/lib/views/widgets/status/report/service_report_visit_date_operator.dart b/lib/views/widgets/status/report/service_report_visit_date_operator.dart index 664e25ea..629e5d71 100644 --- a/lib/views/widgets/status/report/service_report_visit_date_operator.dart +++ b/lib/views/widgets/status/report/service_report_visit_date_operator.dart @@ -10,7 +10,7 @@ // final Function(Lookup) onSelect; // final Lookup initialValue; // -// const ServiceReportVisitDateOperator({Key key, @required this.onSelect, @required this.initialValue}) : super(key: key); +// const ServiceReportVisitDateOperator({Key? key, required this.onSelect, required this.initialValue}) : super(key: key); // // @override // Widget build(BuildContext context) { diff --git a/lib/views/widgets/status/report/service_status.dart b/lib/views/widgets/status/report/service_status.dart index 12847905..0c5b0e19 100644 --- a/lib/views/widgets/status/report/service_status.dart +++ b/lib/views/widgets/status/report/service_status.dart @@ -12,7 +12,7 @@ // final Function(Lookup) onSelect; // final Lookup initialValue; // -// const ServiceAssetTypeMenu({Key key, this.onSelect, this.initialValue}) : super(key: key); +// const ServiceAssetTypeMenu({Key? key, this.onSelect, this.initialValue}) : super(key: key); // // @override // Widget build(BuildContext context) { diff --git a/lib/views/widgets/status/service_request/service_request_defect_types_mune.dart b/lib/views/widgets/status/service_request/service_request_defect_types_mune.dart index 59adcce5..1f88d91e 100644 --- a/lib/views/widgets/status/service_request/service_request_defect_types_mune.dart +++ b/lib/views/widgets/status/service_request/service_request_defect_types_mune.dart @@ -13,7 +13,7 @@ // final Lookup initialValue; // final bool enabled; // -// const ServiceRequestDefectTypesMenu({Key key, this.onSelect, this.initialValue, this.enabled = true}) : super(key: key); +// const ServiceRequestDefectTypesMenu({Key? key, this.onSelect, this.initialValue, this.enabled = true}) : super(key: key); // // @override // Widget build(BuildContext context) { diff --git a/lib/views/widgets/status/service_request/service_request_first_action.dart b/lib/views/widgets/status/service_request/service_request_first_action.dart index d7089ae8..8f527c3e 100644 --- a/lib/views/widgets/status/service_request/service_request_first_action.dart +++ b/lib/views/widgets/status/service_request/service_request_first_action.dart @@ -14,7 +14,7 @@ // final Lookup initialValue; // final bool enabled; // -// const ServiceRequestedFirstAction({Key key, this.onSelect, this.initialValue, this.enabled = true}) : super(key: key); +// const ServiceRequestedFirstAction({Key? key, this.onSelect, this.initialValue, this.enabled = true}) : super(key: key); // // @override // Widget build(BuildContext context) { diff --git a/lib/views/widgets/status/service_request/service_request_loan_availability.dart b/lib/views/widgets/status/service_request/service_request_loan_availability.dart index 82a5fa40..3318049f 100644 --- a/lib/views/widgets/status/service_request/service_request_loan_availability.dart +++ b/lib/views/widgets/status/service_request/service_request_loan_availability.dart @@ -14,7 +14,7 @@ // final Function(Lookup) onSelect; // final Lookup initialValue; // -// const ServiceRequestedLoanAvailability({Key key, this.onSelect, this.initialValue}) : super(key: key); +// const ServiceRequestedLoanAvailability({Key? key, this.onSelect, this.initialValue}) : super(key: key); // // @override // Widget build(BuildContext context) { diff --git a/lib/views/widgets/status/service_request/service_request_priority_mune.dart b/lib/views/widgets/status/service_request/service_request_priority_mune.dart index 6c128aba..c02d03c9 100644 --- a/lib/views/widgets/status/service_request/service_request_priority_mune.dart +++ b/lib/views/widgets/status/service_request/service_request_priority_mune.dart @@ -13,7 +13,7 @@ // final Lookup initialValue; // final bool enabled; // -// const ServiceRequestPriorityMenu({Key key, this.onSelect, this.initialValue, this.enabled}) : super(key: key); +// const ServiceRequestPriorityMenu({Key? key, this.onSelect, this.initialValue, this.enabled}) : super(key: key); // // @override // Widget build(BuildContext context) { diff --git a/lib/views/widgets/status/service_request/service_request_status_mune.dart b/lib/views/widgets/status/service_request/service_request_status_mune.dart index ec972ce1..08e33b7b 100644 --- a/lib/views/widgets/status/service_request/service_request_status_mune.dart +++ b/lib/views/widgets/status/service_request/service_request_status_mune.dart @@ -12,7 +12,7 @@ // final Function(Lookup) onSelect; // final Lookup initialValue; // -// const ServiceRequestStatusMenu({Key key, this.onSelect, this.initialValue}) : super(key: key); +// const ServiceRequestStatusMenu({Key? key, this.onSelect, this.initialValue}) : super(key: key); // // @override // Widget build(BuildContext context) { diff --git a/lib/views/widgets/status/service_request/service_request_through_mune.dart b/lib/views/widgets/status/service_request/service_request_through_mune.dart index 43f67127..d157646e 100644 --- a/lib/views/widgets/status/service_request/service_request_through_mune.dart +++ b/lib/views/widgets/status/service_request/service_request_through_mune.dart @@ -13,7 +13,7 @@ // final Lookup initialValue; // final bool enabled; // -// const ServiceRequestedThroughMenu({Key key, this.onSelect, this.initialValue, this.enabled = true}) : super(key: key); +// const ServiceRequestedThroughMenu({Key? key, this.onSelect, this.initialValue, this.enabled = true}) : super(key: key); // // @override // Widget build(BuildContext context) { diff --git a/lib/views/widgets/status/service_request/service_request_types_mune.dart b/lib/views/widgets/status/service_request/service_request_types_mune.dart index d3a92465..e951aa5c 100644 --- a/lib/views/widgets/status/service_request/service_request_types_mune.dart +++ b/lib/views/widgets/status/service_request/service_request_types_mune.dart @@ -14,7 +14,7 @@ // final bool enabled; // final bool withDefaultItem; // -// const ServiceRequestTypesMenu({Key key, this.onSelect, this.initialValue, this.withDefaultItem = false, this.enabled = true}) : super(key: key); +// const ServiceRequestTypesMenu({Key? key, this.onSelect, this.initialValue, this.withDefaultItem = false, this.enabled = true}) : super(key: key); // // @override // Widget build(BuildContext context) { diff --git a/lib/views/widgets/status/service_request/supplier_engineers_menu.dart b/lib/views/widgets/status/service_request/supplier_engineers_menu.dart index f619ab5c..ec5131e7 100644 --- a/lib/views/widgets/status/service_request/supplier_engineers_menu.dart +++ b/lib/views/widgets/status/service_request/supplier_engineers_menu.dart @@ -10,7 +10,7 @@ // final SuppEngineerWorkOrders initialValue; // final Function(SuppEngineerWorkOrders) onSelect; // -// const SupplierEngineersMenu({Key key, this.engineers, this.onSelect, this.initialValue}) : super(key: key); +// const SupplierEngineersMenu({Key? key, this.engineers, this.onSelect, this.initialValue}) : super(key: key); // // @override // SingleAssistantEmployeeMenuState createState() => SingleAssistantEmployeeMenuState(); diff --git a/lib/views/widgets/status/single_status_menu.dart b/lib/views/widgets/status/single_status_menu.dart index 41ffdad1..8b7a13dc 100644 --- a/lib/views/widgets/status/single_status_menu.dart +++ b/lib/views/widgets/status/single_status_menu.dart @@ -1,25 +1,32 @@ import 'package:flutter/material.dart'; import 'package:test_sa/extensions/context_extension.dart'; -import 'package:test_sa/extensions/int_extensions.dart'; +import'package:test_sa/extensions/int_extensions.dart'; import 'package:test_sa/models/lookup.dart'; import '../../../new_views/app_style/app_color.dart'; class SingleStatusMenu extends StatefulWidget { - final List statuses; - final Lookup initialStatus; - final Function(Lookup) onSelect; + final List? statuses;// Nullable list + final Lookup? initialStatus; // Nullable + final Function(Lookup?)? onSelect; // Nullable function, accepts nullable Lookup final bool enabled; - final String title; + final String? title; // Nullable - const SingleStatusMenu({Key key, this.enabled = true, this.title, this.statuses, this.onSelect, this.initialStatus}) : super(key: key); + const SingleStatusMenu({ + Key? key, + this.enabled = true, + this.title, + this.statuses, + this.onSelect, + this.initialStatus, + }) : super(key: key); @override _SingleStatusMenuState createState() => _SingleStatusMenuState(); } class _SingleStatusMenuState extends State { - Lookup _selectedStatus; + Lookup? _selectedStatus; @override void setState(VoidCallback fn) { @@ -28,34 +35,25 @@ class _SingleStatusMenuState extends State { @override void didUpdateWidget(covariant SingleStatusMenu oldWidget) { - if (widget.initialStatus != null) { - final result = widget.statuses?.where((element) { - return element == widget.initialStatus; - }); - if (result.isNotEmpty) { - _selectedStatus = result.first; - } else { - _selectedStatus = null; - } - if ((widget.initialStatus?.id ?? "") != (_selectedStatus?.id ?? "")) { - widget.onSelect(_selectedStatus); - } - } else { - _selectedStatus = null; + _selectedStatus = widget.statuses?.firstWhere( + (element) => element == widget.initialStatus, + orElse: null); + + if (widget.initialStatus != _selectedStatus) { + widget.onSelect?.call(_selectedStatus); // Use null-aware operator } + super.didUpdateWidget(oldWidget); } @override void initState() { - if (widget.initialStatus != null) { - final result = widget.statuses?.where((element) { - return element == widget.initialStatus; - }); - if (result.isNotEmpty) _selectedStatus = result.first; - if (widget.initialStatus.id != _selectedStatus?.id) { - widget.onSelect(_selectedStatus); - } + _selectedStatus = widget.statuses?.firstWhere( + (element) => element == widget.initialStatus, + orElse: null); + + if (widget.initialStatus != _selectedStatus) { + widget.onSelect?.call(_selectedStatus); // Use null-aware operator } super.initState(); @@ -63,30 +61,35 @@ class _SingleStatusMenuState extends State { @override Widget build(BuildContext context) { - return Container( - height: 60.toScreenHeight, + return Container(height: 60.toScreenHeight, padding: EdgeInsets.symmetric(horizontal: 16.toScreenWidth), decoration: BoxDecoration( - color: context.isDark && (widget.enabled == false || (widget.statuses?.isEmpty ?? true)) + color: context.isDark && (!widget.enabled || widget.statuses!.isEmpty) ? AppColor.neutral50 - : (widget.enabled == false || (widget.statuses?.isEmpty ?? true)) - ? AppColor.neutral40 - : AppColor.background(context), + : (!widget.enabled || widget.statuses!.isEmpty) + ? AppColor.neutral40 + : AppColor.background(context), borderRadius: BorderRadius.circular(10), - boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.05), blurRadius: 10)], + boxShadow: [ + BoxShadow(color: Colors.black.withOpacity(0.05), blurRadius: 10) + ], ), child: Stack( alignment: Alignment.center, children: [ - if (widget.enabled) const PositionedDirectional(end: 0, child: Icon(Icons.keyboard_arrow_down_rounded)), + if (widget.enabled) + const PositionedDirectional( + end: 0, child: Icon(Icons.keyboard_arrow_down_rounded)), Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.center, children: [ if (widget.title != null) Text( - widget.title, - style: Theme.of(context).textTheme.bodySmall?.copyWith(color: context.isDark ? null : AppColor.neutral20, fontWeight: FontWeight.w500), + widget.title!, // Use null assertion operator + style: Theme.of(context).textTheme.bodySmall?.copyWith( + color: context.isDark ? null : AppColor.neutral20, + fontWeight: FontWeight.w500), ), DropdownButton( value: _selectedStatus, @@ -101,23 +104,24 @@ class _SingleStatusMenuState extends State { ), style: TextStyle(color: Theme.of(context).primaryColor), underline: const SizedBox.shrink(), - onChanged: widget.enabled == false + onChanged: !widget.enabled ? null - : (Lookup newValue) { - setState(() { - _selectedStatus = newValue; - }); - widget.onSelect(newValue); - }, - items: widget.statuses?.map>((value) { + : (Lookup? newValue) { // Nullable Lookup + setState(() { + _selectedStatus = newValue; + }); + widget.onSelect?.call(newValue); // Use null-aware operator + }, + items: widget.statuses + ?.map>((value) { return DropdownMenuItem( value: value, - child: Text( - value?.name ?? "", + child: Text(value.name ?? "", // Use null-aware operator style: Theme.of(context).textTheme.bodyLarge, ), ); - })?.toList(), + }) + .toList(), ), ], ), @@ -125,4 +129,4 @@ class _SingleStatusMenuState extends State { ), ); } -} +} \ No newline at end of file diff --git a/lib/views/widgets/status/users_menu.dart b/lib/views/widgets/status/users_menu.dart index ceae41d0..c7ef49ea 100644 --- a/lib/views/widgets/status/users_menu.dart +++ b/lib/views/widgets/status/users_menu.dart @@ -9,7 +9,7 @@ // final Employee initialStatus; // final Function(Employee) onSelect; // -// const UsersMenu({Key key, this.statuses, this.onSelect, this.initialStatus}) : super(key: key); +// const UsersMenu({Key? key, this.statuses, this.onSelect, this.initialStatus}) : super(key: key); // // @override // _SingleUsersMenuState createState() => _SingleUsersMenuState(); diff --git a/lib/views/widgets/switch_button.dart b/lib/views/widgets/switch_button.dart index b5426b82..111b5dc9 100644 --- a/lib/views/widgets/switch_button.dart +++ b/lib/views/widgets/switch_button.dart @@ -10,10 +10,10 @@ // final void Function(bool) onChange; // // const ASwitchButton({ -// @required this.title, -// @required this.value, -// @required this.onChange, -// Key key, +// required this.title, +// required this.value, +// required this.onChange, +// Key? key, // }) : super(key: key); // // @override diff --git a/lib/views/widgets/titles/app_sub_title.dart b/lib/views/widgets/titles/app_sub_title.dart index 579909a6..3f5e0b6e 100644 --- a/lib/views/widgets/titles/app_sub_title.dart +++ b/lib/views/widgets/titles/app_sub_title.dart @@ -7,7 +7,7 @@ // final Color color; // final double font; // -// const ASubTitle(this.text, {Key key, this.padding, this.color, this.font}) : super(key: key); +// const ASubTitle(this.text, {Key? key, this.padding, this.color, this.font}) : super(key: key); // // @override // Widget build(BuildContext context) { diff --git a/lib/views/widgets/titles/app_title.dart b/lib/views/widgets/titles/app_title.dart index 14a79e5b..4cde4fdd 100644 --- a/lib/views/widgets/titles/app_title.dart +++ b/lib/views/widgets/titles/app_title.dart @@ -7,7 +7,7 @@ // final EdgeInsets padding; // final bool center; // -// const ATitle(this.text, {Key key, this.padding, this.center = false}) : super(key: key); +// const ATitle(this.text, {Key? key, this.padding, this.center = false}) : super(key: key); // // @override // Widget build(BuildContext context) { diff --git a/lib/views/widgets/titles/expandable_info_row.dart b/lib/views/widgets/titles/expandable_info_row.dart index ff52f44b..1fa817fe 100644 --- a/lib/views/widgets/titles/expandable_info_row.dart +++ b/lib/views/widgets/titles/expandable_info_row.dart @@ -8,7 +8,7 @@ // final String title; // final Widget child; // -// const ExpandableInfoRow({Key key, this.iconData, this.title, this.child}) : super(key: key); +// const ExpandableInfoRow({Key? key, this.iconData, this.title, this.child}) : super(key: key); // // @override // _ExpandableInfoRowState createState() => _ExpandableInfoRowState(); diff --git a/pubspec.lock b/pubspec.lock index bdc00476..d90b108d 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -689,10 +689,10 @@ packages: dependency: "direct main" description: name: intl - sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d" + sha256: d6f56758b7d3014a48af9701c085700aac781a92a87a62b1333b46d8879661cf url: "https://pub.dev" source: hosted - version: "0.18.1" + version: "0.19.0" js: dependency: transitive description: @@ -709,6 +709,30 @@ packages: url: "https://pub.dev" source: hosted version: "4.8.1" + leak_tracker: + dependency: transitive + description: + name: leak_tracker + sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05" + url: "https://pub.dev" + source: hosted + version: "10.0.5" + leak_tracker_flutter_testing: + dependency: transitive + description: + name: leak_tracker_flutter_testing + sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806" + url: "https://pub.dev" + source: hosted + version: "3.0.5" + leak_tracker_testing: + dependency: transitive + description: + name: leak_tracker_testing + sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" + url: "https://pub.dev" + source: hosted + version: "3.0.1" lints: dependency: transitive description: @@ -721,26 +745,26 @@ packages: dependency: "direct main" description: name: local_auth - sha256: "0cf238be2bfa51a6c9e7e9cfc11c05ea39f2a3a4d3e5bb255d0ebc917da24401" + sha256: "434d854cf478f17f12ab29a76a02b3067f86a63a6d6c4eb8fbfdcfe4879c1b7b" url: "https://pub.dev" source: hosted - version: "2.1.6" + version: "2.3.0" local_auth_android: dependency: transitive description: name: local_auth_android - sha256: "523dd636ce061ddb296cbc3db410cb8f21efb7d8798f7b9532c8038ce2f8bad5" + sha256: e9a3c321e94359a552b1bdd0f98f79885f2b3e27234d270f9bef5cd82b29340c url: "https://pub.dev" source: hosted - version: "1.0.31" - local_auth_ios: + version: "1.0.44" + local_auth_darwin: dependency: transitive description: - name: local_auth_ios - sha256: edc2977c5145492f3451db9507a2f2f284ee4f408950b3e16670838726761940 + name: local_auth_darwin + sha256: "7ba5738c874ca2b910d72385d00d2bebad9d4e807612936cf5e32bc01a048c71" url: "https://pub.dev" source: hosted - version: "1.1.3" + version: "1.4.0" local_auth_platform_interface: dependency: transitive description: @@ -785,26 +809,26 @@ packages: dependency: transitive description: name: matcher - sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" + sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb url: "https://pub.dev" source: hosted - version: "0.12.16" + version: "0.12.16+1" material_color_utilities: dependency: transitive description: name: material_color_utilities - sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" + sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec url: "https://pub.dev" source: hosted - version: "0.5.0" + version: "0.11.1" meta: dependency: transitive description: name: meta - sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e + sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7 url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.15.0" mime: dependency: transitive description: @@ -849,10 +873,10 @@ packages: dependency: transitive description: name: path - sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" url: "https://pub.dev" source: hosted - version: "1.8.3" + version: "1.9.0" path_drawing: dependency: transitive description: @@ -1262,10 +1286,10 @@ packages: dependency: "direct main" description: name: table_calendar - sha256: "1e3521a3e6d3fc7f645a58b135ab663d458ab12504f1ea7f9b4b81d47086c478" + sha256: "4ca32b2fc919452c9974abd4c6ea611a63e33b9e4f0b8c38dba3ac1f4a6549d1" url: "https://pub.dev" source: hosted - version: "3.0.9" + version: "3.1.2" term_glyph: dependency: transitive description: @@ -1278,10 +1302,10 @@ packages: dependency: transitive description: name: test_api - sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" + sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb" url: "https://pub.dev" source: hosted - version: "0.6.1" + version: "0.7.2" timezone: dependency: transitive description: @@ -1386,14 +1410,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.4" - web: + vm_service: dependency: transitive description: - name: web - sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152 + name: vm_service + sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d" url: "https://pub.dev" source: hosted - version: "0.3.0" + version: "14.2.5" win32: dependency: transitive description: @@ -1427,5 +1451,5 @@ packages: source: hosted version: "3.1.2" sdks: - dart: ">=3.2.0-194.0.dev <4.0.0" - flutter: ">=3.16.0" + dart: ">=3.5.0 <4.0.0" + flutter: ">=3.24.0" diff --git a/pubspec.yaml b/pubspec.yaml index 76c63561..ff17afa5 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -50,7 +50,7 @@ dependencies: flutter_local_notifications: ^12.0.1+1 cached_network_image: ^3.2.2 carousel_slider: ^4.1.1 - intl: ^0.18.0 + intl: ^0.19.0 flutter_typeahead: ^4.1.1 speech_to_text: ^6.1.1 firebase_core: ^2.4.0 @@ -81,7 +81,7 @@ dependencies: # buttons_tabbar: ^1.1.2 flutter_custom_month_picker: ^0.1.3 syncfusion_flutter_charts: ^21.2.3 - local_auth: ^2.1.6 + local_auth: ^2.3.0 dev_dependencies: flutter_test: