From 2f013ba1ad16b21caa0b637970d6371581fb5b7b Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Wed, 29 Jun 2022 11:05:24 +0300 Subject: [PATCH] lint rules added. --- analysis_options.yaml | 10 +++++++++- lib/api/api_client.dart | 1 + lib/classes/utils.dart | 4 +--- lib/ui/attendance/monthly_attendance.dart | 8 ++++---- .../dynamic_screens/dynamic_input_screen.dart | 4 ++-- lib/ui/profile/basic_details.dart | 8 ++++---- .../dynamic_screens/dynamic_input_profile_screen.dart | 7 ++----- lib/ui/profile/profile.dart | 6 +++--- lib/ui/screens/mowadhafhi/mowadhafhi_hr_request.dart | 3 +-- .../pending_transactions/pending_transactions.dart | 2 +- lib/ui/work_list/worklist_detail_screen.dart | 2 +- 11 files changed, 29 insertions(+), 26 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index fa4efae..a84033c 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -14,6 +14,10 @@ analyzer: always_use_package_imports: error camel_case_types: error always_declare_return_types: error + null_check_on_nullable_type_parameter: error + avoid_annotating_with_dynamic: error + unnecessary_null_checks: error + unnecessary_brace_in_string_interps: error linter: @@ -36,11 +40,15 @@ linter: unnecessary_this: true unnecessary_new: true camel_case_types: true + null_check_on_nullable_type_parameter: true sort_child_properties_last: true - camel_case_extensions : true + camel_case_extensions: true require_trailing_commas: true avoid_empty_else: true avoid_annotating_with_dynamic: true + unnecessary_null_checks: true + unnecessary_brace_in_string_interps: true + unnecessary_string_interpolations: true # avoid_print: false # Uncomment to disable the `avoid_print` rule # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule diff --git a/lib/api/api_client.dart b/lib/api/api_client.dart index f4d5f30..2f53f78 100644 --- a/lib/api/api_client.dart +++ b/lib/api/api_client.dart @@ -8,6 +8,7 @@ import 'package:http/io_client.dart'; import 'package:mohem_flutter_app/app_state/app_state.dart'; import 'package:mohem_flutter_app/exceptions/api_exception.dart'; import 'package:mohem_flutter_app/main.dart'; +// ignore_for_file: avoid_annotating_with_dynamic typedef FactoryConstructor = U Function(dynamic); diff --git a/lib/classes/utils.dart b/lib/classes/utils.dart index 424d656..292bc4c 100644 --- a/lib/classes/utils.dart +++ b/lib/classes/utils.dart @@ -8,8 +8,6 @@ import 'package:fluttertoast/fluttertoast.dart'; import 'package:mohem_flutter_app/app_state/app_state.dart'; import 'package:mohem_flutter_app/classes/colors.dart'; import 'package:mohem_flutter_app/config/routes.dart'; - -// import 'package:fluttertoast/fluttertoast.dart'; import 'package:mohem_flutter_app/exceptions/api_exception.dart'; import 'package:mohem_flutter_app/extensions/int_extensions.dart'; import 'package:mohem_flutter_app/extensions/string_extensions.dart'; @@ -18,7 +16,7 @@ import 'package:mohem_flutter_app/generated/locale_keys.g.dart'; import 'package:mohem_flutter_app/widgets/dialogs/confirm_dialog.dart'; import 'package:mohem_flutter_app/widgets/loading_dialog.dart'; import 'package:shared_preferences/shared_preferences.dart'; -import 'package:sizer/sizer.dart'; +// ignore_for_file: avoid_annotating_with_dynamic class Utils { static bool _isLoadingVisible = false; diff --git a/lib/ui/attendance/monthly_attendance.dart b/lib/ui/attendance/monthly_attendance.dart index 70afd40..de5c9c9 100644 --- a/lib/ui/attendance/monthly_attendance.dart +++ b/lib/ui/attendance/monthly_attendance.dart @@ -327,7 +327,7 @@ class _MonthlyAttendanceState extends State { ), alignment: Alignment.center, child: Text( - "${val}", + "$val", style: const TextStyle( fontSize: 13, fontWeight: FontWeight.w500, @@ -358,7 +358,7 @@ class _MonthlyAttendanceState extends State { ), alignment: Alignment.center, child: Text( - "${val}", + "$val", style: const TextStyle( fontSize: 13, fontWeight: FontWeight.w500, @@ -384,7 +384,7 @@ class _MonthlyAttendanceState extends State { ), alignment: Alignment.center, child: Text( - "${val}", + "$val", style: const TextStyle( fontSize: 13, fontWeight: FontWeight.w500, @@ -408,7 +408,7 @@ class _MonthlyAttendanceState extends State { ), alignment: Alignment.center, child: Text( - "${val}", + "$val", style: const TextStyle( fontSize: 13, fontWeight: FontWeight.w500, diff --git a/lib/ui/my_attendance/dynamic_screens/dynamic_input_screen.dart b/lib/ui/my_attendance/dynamic_screens/dynamic_input_screen.dart index 96c1a02..ef75031 100644 --- a/lib/ui/my_attendance/dynamic_screens/dynamic_input_screen.dart +++ b/lib/ui/my_attendance/dynamic_screens/dynamic_input_screen.dart @@ -125,7 +125,7 @@ class _DynamicInputScreenState extends State { Utils.showLoading(context); for (int i = 0; i < (structureList.cHILDSEGMENTSDVSplited?.length ?? 0); i++) { String segmentId = structureList.cHILDSEGMENTSDVSplited![i]; - print("segmentId:${segmentId}"); + print("segmentId:$segmentId"); print("segmentName:${structureList.sEGMENTNAME}"); GetEITDFFStructureList? parent = getEitDffStructureList!.firstWhere((element) => element.sEGMENTNAME == segmentId); List parentRequired = parent.pARENTSEGMENTSDVSplited ?? []; @@ -139,7 +139,7 @@ class _DynamicInputScreenState extends State { sEGMENTNAME: e.sEGMENTNAME, vALUECOLUMNNAME: e.eSERVICESDV!.pVALUECOLUMNNAME, dESCRIPTION: "", iDCOLUMNNAME: e.eSERVICESDV!.pIDCOLUMNNAME, fLEXVALUESETNAME: e.fLEXVALUESETNAME) .toJson()) .toList(); - print("values:${values}"); + print("values:$values"); ESERVICESDV defaultValue = await MyAttendanceApiClient().getDefaultValue(segmentId, structureList.dESCFLEXCONTEXTCODE!, structureList.dESCFLEXNAME!, values); int index = getEitDffStructureList!.indexWhere((element) => element.sEGMENTNAME == segmentId); diff --git a/lib/ui/profile/basic_details.dart b/lib/ui/profile/basic_details.dart index ab00560..d825c2b 100644 --- a/lib/ui/profile/basic_details.dart +++ b/lib/ui/profile/basic_details.dart @@ -111,22 +111,22 @@ class _BasicDetailsState extends State { ), child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ LocaleKeys.fullName.tr().toText13(color: MyColors.lightGrayColor), - "${fullName}".toText16(isBold: true, color: MyColors.blackColor), + "$fullName".toText16(isBold: true, color: MyColors.blackColor), SizedBox( height: 20, ), LocaleKeys.maritalStatus.tr().toText13(color: MyColors.lightGrayColor), - "${maritalStatus}".toText16(isBold: true, color: MyColors.blackColor), + "$maritalStatus".toText16(isBold: true, color: MyColors.blackColor), SizedBox( height: 20, ), LocaleKeys.dateOfBirth.tr().toText13(color: MyColors.lightGrayColor), - "${birthDate}".toText16(isBold: true, color: MyColors.blackColor), + "$birthDate".toText16(isBold: true, color: MyColors.blackColor), SizedBox( height: 20, ), LocaleKeys.civilIdentityNumber.tr().toText13(color: MyColors.lightGrayColor), - "${civilIdentityNumber}".toText16(isBold: true, color: MyColors.blackColor), + "$civilIdentityNumber".toText16(isBold: true, color: MyColors.blackColor), ]), ), ], diff --git a/lib/ui/profile/dynamic_screens/dynamic_input_profile_screen.dart b/lib/ui/profile/dynamic_screens/dynamic_input_profile_screen.dart index dc84bee..6fe8046 100644 --- a/lib/ui/profile/dynamic_screens/dynamic_input_profile_screen.dart +++ b/lib/ui/profile/dynamic_screens/dynamic_input_profile_screen.dart @@ -1,6 +1,5 @@ import 'dart:io'; - import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -31,7 +30,6 @@ class DynamicProfileParams { String colsURL; List? getEmployeeBasicDetailsList; - DynamicProfileParams(this.title, this.dynamicId, {this.uRL = 'GET_EIT_DFF_STRUCTURE', this.requestID = '', this.colsURL = '', this.getEmployeeBasicDetailsList = const []}); } @@ -183,7 +181,7 @@ class _DynamicInputScreenState extends State { for (int i = 0; i < model.eSERVICESVS!.length; i++) PopupMenuItem(child: Text(model.eSERVICESVS![i].vALUECOLUMNNAME!), value: i), ], onSelected: (int popupIndex) { - getBasicDetDffStructureList![index].userBasicDetail!.sEGMENTVALUEDSP = model.eSERVICESVS![popupIndex].vALUECOLUMNNAME!; + getBasicDetDffStructureList![index].userBasicDetail!.sEGMENTVALUEDSP = model.eSERVICESVS![popupIndex].vALUECOLUMNNAME; setState(() {}); }); } @@ -194,7 +192,6 @@ class _DynamicInputScreenState extends State { isReadOnly: model.rEADONLY == "Y", onChange: (text) { getBasicDetDffStructureList![index].userBasicDetail!.sEGMENTVALUEDSP = text; - }, ).paddingOnly(bottom: 12); } else if (model.fORMATTYPE == "X") { @@ -249,7 +246,7 @@ class _DynamicInputScreenState extends State { onSelected: (int popupIndex) { ESERVICESDV eservicesdv = ESERVICESDV(pIDCOLUMNNAME: model.objectValuesList![index].dESCRIPTION, pRETURNMSG: "null", pRETURNSTATUS: model.oBJECTNAME, pVALUECOLUMNNAME: model.aPPLICATIONCOLUMNNAME); - getBasicDetDffStructureList![index].userBasicDetail!.sEGMENTVALUEDSP = model.objectValuesList![popupIndex].dESCRIPTION!; + getBasicDetDffStructureList![index].userBasicDetail!.sEGMENTVALUEDSP = model.objectValuesList![popupIndex].dESCRIPTION; setState(() {}); }); } diff --git a/lib/ui/profile/profile.dart b/lib/ui/profile/profile.dart index 46fe7ea..22d062b 100644 --- a/lib/ui/profile/profile.dart +++ b/lib/ui/profile/profile.dart @@ -124,9 +124,9 @@ class _ProfileState extends State { ), child: Column( children: [ - "${fullName}".toText20(isBold: true, color: MyColors.blackColor), - "${employeeNo}".toText12(isBold: false, color: MyColors.lightGrayColor), - "${emailAddress}".toText12(isBold: false, color: MyColors.black), + "$fullName".toText20(isBold: true, color: MyColors.blackColor), + "$employeeNo".toText12(isBold: false, color: MyColors.lightGrayColor), + "$emailAddress".toText12(isBold: false, color: MyColors.black), SizedBox( height: 5, ), diff --git a/lib/ui/screens/mowadhafhi/mowadhafhi_hr_request.dart b/lib/ui/screens/mowadhafhi/mowadhafhi_hr_request.dart index 6ed9cb5..4ee819d 100644 --- a/lib/ui/screens/mowadhafhi/mowadhafhi_hr_request.dart +++ b/lib/ui/screens/mowadhafhi/mowadhafhi_hr_request.dart @@ -95,7 +95,6 @@ class _MowadhafhiHRRequestState extends State { groupValue: selectedServiceType, selectedColor: MyColors.gradiantStartColor), ).onPress(() { - debugPrint(getTicketTypesList[index].typeName!); selectedServiceType = getTicketTypesList[index].ticketTypeId!.toString(); setState(() {}); }); @@ -314,7 +313,7 @@ class _MowadhafhiHRRequestState extends State { getMowadhafhiProjectsList = await MowadhafhiApiClient().getProjects(); Utils.hideLoading(context); getProjectDepartments(getMowadhafhiProjectsList[0].projectId!); - projectID = getMowadhafhiProjectsList[0].projectId!; + projectID = getMowadhafhiProjectsList[0].projectId; } catch (ex) { Utils.hideLoading(context); Utils.handleException(ex, context, null); diff --git a/lib/ui/screens/pending_transactions/pending_transactions.dart b/lib/ui/screens/pending_transactions/pending_transactions.dart index e074ad7..98d7fe3 100644 --- a/lib/ui/screens/pending_transactions/pending_transactions.dart +++ b/lib/ui/screens/pending_transactions/pending_transactions.dart @@ -76,7 +76,7 @@ class _PendingTransactionsState extends State { for (int i = 0; i < getPendingTransactionsFunctions!.length; i++) PopupMenuItem(child: Text(getPendingTransactionsFunctions![i].fUNCTIONPROMPT!), value: i), ], onSelected: (int popupIndex) { - selectedFunction = getPendingTransactionsFunctions![popupIndex]; + selectedFunction = getPendingTransactionsFunctions[popupIndex]; setState(() {}); }), 12.height, diff --git a/lib/ui/work_list/worklist_detail_screen.dart b/lib/ui/work_list/worklist_detail_screen.dart index 1166d83..6ad0a79 100644 --- a/lib/ui/work_list/worklist_detail_screen.dart +++ b/lib/ui/work_list/worklist_detail_screen.dart @@ -485,7 +485,7 @@ class _WorkListDetailScreenState extends State { "P_APPROVER_INDEX": null, "P_COMMENTS": "", "P_FORWARD_TO_USER_NAME": "", - "P_NOTIFICATION_ID": workListData!.nOTIFICATIONID!, + "P_NOTIFICATION_ID": workListData!.nOTIFICATIONID, "RespondAttributeList": [ if (notificationNoteInput != null) {notificationNoteInput!.attributeName: note} ],