From 4eb7b87bdb7d7a3cd1e4fb17c703eb71179766b2 Mon Sep 17 00:00:00 2001 From: Rainvisitor Date: Sun, 7 Jan 2024 01:33:24 +0800 Subject: [PATCH] chore: code tune for dart 2.19 lint --- lib/api/ap_helper.dart | 6 +-- lib/api/bus_helper.dart | 8 +-- lib/api/leave_helper.dart | 2 +- lib/api/mobile_nkust_helper.dart | 12 +++-- lib/api/nkust_helper.dart | 2 +- lib/api/parser/ap_parser.dart | 53 ++++++++++--------- lib/api/parser/bus_parser.dart | 2 +- lib/api/parser/leave_parser.dart | 4 +- lib/api/parser/mobile_nkust_parser.dart | 2 +- lib/pages/bus/bus_page.dart | 4 +- lib/pages/bus/bus_reservations_page.dart | 4 +- lib/pages/bus/bus_reserve_page.dart | 4 +- lib/pages/bus/bus_violation_records_page.dart | 2 +- lib/pages/info/schedule_page.dart | 2 +- lib/pages/leave/leave_apply_page.dart | 2 +- lib/pages/leave/leave_record_page.dart | 4 +- lib/pages/login_page.dart | 2 +- lib/pages/search_student_id_page.dart | 2 +- lib/pages/study/calculate_units_page.dart | 2 +- lib/utils/date_utils.dart | 2 +- lib/widgets/flutter_calendar.dart | 2 +- lib/widgets/semester_picker.dart | 6 ++- 22 files changed, 68 insertions(+), 61 deletions(-) diff --git a/lib/api/ap_helper.dart b/lib/api/ap_helper.dart index 008bac96..b8bd1e49 100644 --- a/lib/api/ap_helper.dart +++ b/lib/api/ap_helper.dart @@ -138,7 +138,7 @@ class WebApHelper { data: { 'uid': username, 'pwd': password, - 'etxt_code': captchaCode + 'etxt_code': captchaCode, }, options: Options(contentType: 'application/x-www-form-urlencoded'), ); @@ -273,7 +273,7 @@ class WebApHelper { 'https://leave.nkust.edu.tw/SkyDir.aspx', queryParameters: { 'u': skyDirectData['uid'], - 'r': skyDirectData['ls_randnum'] + 'r': skyDirectData['ls_randnum'], }, options: Options( followRedirects: false, @@ -546,7 +546,7 @@ class WebApHelper { 'ag302_01', { 'yms_yms': '$years#$semesterValue', - 'cmp_area_id': cmpAreaId + 'cmp_area_id': cmpAreaId, }, ); diff --git a/lib/api/bus_helper.dart b/lib/api/bus_helper.dart index 70c2eeee..e65b84aa 100644 --- a/lib/api/bus_helper.dart +++ b/lib/api/bus_helper.dart @@ -96,7 +96,7 @@ class BusEncrypt { 'c': i, 'd': j, 'e': k, - 'f': passwordMD5 + 'f': passwordMD5, }, ); } @@ -222,7 +222,7 @@ class BusHelper { 'n': busEncryptObject.loginEncrypt( Helper.username!, Helper.password!, - ) + ), }, options: Options(contentType: Headers.formUrlEncodedContentType), ); @@ -262,7 +262,7 @@ class BusHelper { 'operation': '全部', 'page': 1, 'start': 0, - 'limit': 90 + 'limit': 90, }; options = Options(contentType: Headers.formUrlEncodedContentType); } else { @@ -277,7 +277,7 @@ class BusHelper { 'operation': '全部', 'page': 1, 'start': 0, - 'limit': 90 + 'limit': 90, }, ); options = buildCacheOptions( diff --git a/lib/api/leave_helper.dart b/lib/api/leave_helper.dart index e995ae72..af4b716b 100644 --- a/lib/api/leave_helper.dart +++ b/lib/api/leave_helper.dart @@ -73,7 +73,7 @@ class LeaveHelper { 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8', 'Referer': 'https://leave.nkust.edu.tw/LogOn.aspx', 'Accept-Encoding': 'gzip, deflate', - 'Accept-Language': 'zh-TW,zh;q=0.9,en-US;q=0.8,en;q=0.7,ja;q=0.6' + 'Accept-Language': 'zh-TW,zh;q=0.9,en-US;q=0.8,en;q=0.7,ja;q=0.6', }); dio.options.headers['Connection'] = 'close'; diff --git a/lib/api/mobile_nkust_helper.dart b/lib/api/mobile_nkust_helper.dart index f2400711..01d2183c 100644 --- a/lib/api/mobile_nkust_helper.dart +++ b/lib/api/mobile_nkust_helper.dart @@ -91,7 +91,7 @@ class MobileNkustHelper { 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1623.0 Safari/537.36', 'Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML like Gecko) Chrome/44.0.2403.155 Safari/537.36', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124 Safari/537.36', - 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.93 Safari/537.36' + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.93 Safari/537.36', ]; String? get userAgent => dio.options.headers['user-agent'] as String?; @@ -167,7 +167,9 @@ class MobileNkustHelper { if (data != null) { if (otherRequestUrl != null) { final Map requestData = { - '__RequestVerificationToken': MobileNkustParser.getCSRF(response.data) + '__RequestVerificationToken': MobileNkustParser.getCSRF( + response.data, + ), }; requestData.addAll(data); @@ -369,7 +371,7 @@ class MobileNkustHelper { 'driveDate': '$year/$month/$day', 'beginStation': requestData[0], 'endStation': requestData[1], - '__RequestVerificationToken': MobileNkustParser.getCSRF(request.data) + '__RequestVerificationToken': MobileNkustParser.getCSRF(request.data), }, options: Options( contentType: Headers.formUrlEncodedContentType, @@ -469,7 +471,7 @@ class MobileNkustHelper { 'endStation': requestData[1], 'pageNum': 1, 'pageSize': 99, - '__RequestVerificationToken': MobileNkustParser.getCSRF(request.data) + '__RequestVerificationToken': MobileNkustParser.getCSRF(request.data), }, options: Options( contentType: Headers.formUrlEncodedContentType, @@ -514,7 +516,7 @@ class MobileNkustHelper { 'Referer': homeUrl, }, otherRequestHeader: { - 'Referer': busViolationRecordsPageUrl + 'Referer': busViolationRecordsPageUrl, }, ); // not pay request diff --git a/lib/api/nkust_helper.dart b/lib/api/nkust_helper.dart index ed68312a..532420e6 100644 --- a/lib/api/nkust_helper.dart +++ b/lib/api/nkust_helper.dart @@ -106,7 +106,7 @@ class NKUSTHelper { 'data': { 'page': page + 1, 'notification': acadData, - } + }, }); } } diff --git a/lib/api/parser/ap_parser.dart b/lib/api/parser/ap_parser.dart index 0af04c59..d6187149 100644 --- a/lib/api/parser/ap_parser.dart +++ b/lib/api/parser/ap_parser.dart @@ -9,6 +9,9 @@ import 'package:html/dom.dart'; import 'package:html/parser.dart' show parse; import 'package:nkust_ap/api/helper.dart'; +//TODO confirm this rule +//ignore_for_file: unreachable_from_main + final String specialSpace = String.fromCharCode(160); class WebApParser { @@ -111,7 +114,7 @@ class WebApParser { 'className': null, 'id': null, 'name': null, - 'pictureUrl': null + 'pictureUrl': null, }; final Document document = parse(html); final List tdElements = document.getElementsByTagName('td'); @@ -165,8 +168,8 @@ class WebApParser { 'default': { 'year': '108', 'value': '2', - 'text': '108學年第二學期(Parse失敗)' - } + 'text': '108學年第二學期(Parse失敗)', + }, }; final Document document = parse(html); @@ -181,7 +184,7 @@ class WebApParser { { 'year': ymsElements[i].attributes['value']!.split('#')[0], 'value': ymsElements[i].attributes['value']!.split('#')[1], - 'text': ymsElements[i].text + 'text': ymsElements[i].text, }, ); if (ymsElements[i].attributes['selected'] != null) { @@ -189,7 +192,7 @@ class WebApParser { data['default'] = { 'year': ymsElements[i].attributes['value']!.split('#')[0], 'value': ymsElements[i].attributes['value']!.split('#')[1], - 'text': ymsElements[i].text + 'text': ymsElements[i].text, }; } } @@ -205,8 +208,8 @@ class WebApParser { 'conduct': null, 'classRank': null, 'departmentRank': null, - 'average': null - } + 'average': null, + }, }; //detail part try { @@ -223,7 +226,7 @@ class WebApParser { 'departmentRank': matches.elementAt(3).group(1), 'average': (matches.elementAt(1).group(1) != '') ? double.parse(matches.elementAt(1).group(1)!) - : 0.0 + : 0.0, }; } catch (_) {} //scores part @@ -290,7 +293,7 @@ class WebApParser { 'location': { 'building': '', 'room': td[10].text, - } + }, }, ); } @@ -369,7 +372,7 @@ class WebApParser { 'Thursday', 'Friday', 'Saturday', - 'Sunday' + 'Sunday', ]; try { for (int weekdayIndex = 0; @@ -428,7 +431,7 @@ class WebApParser { Map midtermAlertsParser(String? html) { final Map data = { - 'courses': >[] + 'courses': >[], }; final Document document = parse(html); @@ -450,7 +453,7 @@ class WebApParser { 'group': tdData[3].text, 'instructors': tdData[4].text, 'reason': tdData[6].text, - 'remark': tdData[7].text + 'remark': tdData[7].text, }, ); } @@ -464,7 +467,7 @@ class WebApParser { Map rewardAndPenaltyParser(String? html) { final Map data = { - 'data': >[] + 'data': >[], }; final Document document = parse(html); @@ -489,7 +492,7 @@ class WebApParser { 'date': tdData[2].text, 'type': tdData[3].text, 'counts': tdData[4].text, - 'reason': tdData[5].text + 'reason': tdData[5].text, }, ); } @@ -501,7 +504,7 @@ class WebApParser { Map roomListParser(String? html) { final Map data = { - 'data': >[] + 'data': >[], }; final Document document = parse(html); @@ -512,7 +515,7 @@ class WebApParser { (data['data'] as List>).add( { 'roomName': table[i].text, - 'roomId': table[i].attributes['value'] ?? '0035' + 'roomId': table[i].attributes['value'] ?? '0035', }, ); } @@ -543,10 +546,10 @@ class WebApParser { 'Thursday': >[], 'Friday': >[], 'Saturday': >[], - 'Sunday': >[] + 'Sunday': >[], }, '_temp_time': >{}, - 'timeCodes': >[] + 'timeCodes': >[], }; final Map courseTable = @@ -584,8 +587,8 @@ class WebApParser { 'sectionTimes': >[], 'location': null, 'instructors': - td[10].text.replaceAll(specialSpace, '').split(',') - } + td[10].text.replaceAll(specialSpace, '').split(','), + }, }, ); } @@ -620,7 +623,7 @@ class WebApParser { 'Thursday', 'Friday', 'Saturday', - 'Sunday' + 'Sunday', ]; String tmpCourseName = ''; try { @@ -665,8 +668,8 @@ class WebApParser { 'endTime': //ignore: lines_longer_than_80_chars "${courseTime[1].split('-')[1].substring(0, 2)}:${courseTime[1].split('-')[1].substring(2, 4)}", - 'section': tempSection - } + 'section': tempSection, + }, }); if (splitData.length <= 1) { @@ -691,7 +694,7 @@ class WebApParser { 'endTime': //ignore: lines_longer_than_80_chars "${courseTime[1].split('-')[1].substring(0, 2)}:${courseTime[1].split('-')[1].substring(2, 4)}", - 'section': tempSection + 'section': tempSection, }, 'rawInstructors': splitData[1] .replaceAll(specialSpace, '') @@ -740,7 +743,7 @@ class WebApParser { //ignore: avoid_dynamic_calls 'startTime': data['_temp_time'][timeCodeIndex]['startTime'], //ignore: avoid_dynamic_calls - 'endTime': data['_temp_time'][timeCodeIndex]['endTime'] + 'endTime': data['_temp_time'][timeCodeIndex]['endTime'], }); } data.remove('_temp_time'); diff --git a/lib/api/parser/bus_parser.dart b/lib/api/parser/bus_parser.dart index 474030c0..05e53126 100644 --- a/lib/api/parser/bus_parser.dart +++ b/lib/api/parser/bus_parser.dart @@ -41,7 +41,7 @@ Map busTimeTableParser( 'specialTrain': data['data'][i]['SpecialTrain'], 'description': data['data'][i]['SpecialTrainRemark'], 'homeCharteredBus': false, - 'cancelKey': '' + 'cancelKey': '', }; if (temp['SpecialTrain'] == '1') { temp['homeCharteredBus'] = true; diff --git a/lib/api/parser/leave_parser.dart b/lib/api/parser/leave_parser.dart index d6d59d79..84e5be23 100644 --- a/lib/api/parser/leave_parser.dart +++ b/lib/api/parser/leave_parser.dart @@ -52,7 +52,7 @@ Map leaveQueryParser(String? html) { if (tableDom.isEmpty) { return { 'data': >[], - 'timeCodes': [] + 'timeCodes': [], }; } final List trDom = tableDom[0].getElementsByTagName('tr'); @@ -123,7 +123,7 @@ Map? leaveSubmitInfoParser(String? html) { '10', '11', '12', - '13' + '13', ]; } //LeaveType generate part. diff --git a/lib/api/parser/mobile_nkust_parser.dart b/lib/api/parser/mobile_nkust_parser.dart index db4474c8..569b7f87 100644 --- a/lib/api/parser/mobile_nkust_parser.dart +++ b/lib/api/parser/mobile_nkust_parser.dart @@ -108,7 +108,7 @@ class MobileNkustParser { 'location': { 'building': '', 'room': course['CourseRoom'] ?? '', - } + }, }; final bool hasMorning = periodTimeJson[0]['PeriodName'] == 'M'; final List courseWeekPeriod = diff --git a/lib/pages/bus/bus_page.dart b/lib/pages/bus/bus_page.dart index 88833ec5..8ca704d5 100644 --- a/lib/pages/bus/bus_page.dart +++ b/lib/pages/bus/bus_page.dart @@ -35,7 +35,7 @@ class BusPageState extends State with SingleTickerProviderStateMixin { final List _children = [ BusReservePage(), BusReservationsPage(), - BusViolationRecordsPage() + BusViolationRecordsPage(), ]; Future? _login; @@ -73,7 +73,7 @@ class BusPageState extends State with SingleTickerProviderStateMixin { const BusRulePage(), ); }, - ) + ), ], elevation: (_currentIndex == 2) ? 0.0 : null, ), diff --git a/lib/pages/bus/bus_reservations_page.dart b/lib/pages/bus/bus_reservations_page.dart index 85213c47..ccbaf7ac 100644 --- a/lib/pages/bus/bus_reservations_page.dart +++ b/lib/pages/bus/bus_reservations_page.dart @@ -196,7 +196,7 @@ class BusReservationsPageState extends State ? null : () => _showCancelDialog(busReservation), ), - ) + ), ], ), ), @@ -206,7 +206,7 @@ class BusReservationsPageState extends State color: ApTheme.of(context).grey, indent: 4.0, ), - ) + ), ], ); diff --git a/lib/pages/bus/bus_reserve_page.dart b/lib/pages/bus/bus_reserve_page.dart index 76d8e04e..ff59e347 100644 --- a/lib/pages/bus/bus_reserve_page.dart +++ b/lib/pages/bus/bus_reserve_page.dart @@ -313,7 +313,7 @@ class BusReservePageState extends State textAlign: TextAlign.center, style: _textStyle(busTime), ), - ) + ), ], ), ), @@ -321,7 +321,7 @@ class BusReservePageState extends State Container( padding: const EdgeInsets.symmetric(horizontal: 16.0), child: Divider(color: ApTheme.of(context).grey, height: 0.0), - ) + ), ], ); diff --git a/lib/pages/bus/bus_violation_records_page.dart b/lib/pages/bus/bus_violation_records_page.dart index dd06b5d2..351ea2f9 100644 --- a/lib/pages/bus/bus_violation_records_page.dart +++ b/lib/pages/bus/bus_violation_records_page.dart @@ -206,7 +206,7 @@ class _BusViolationRecordsPageState extends State { }, childCount: violationData?.reservations.length ?? 0, ), - ) + ), ], ), ); diff --git a/lib/pages/info/schedule_page.dart b/lib/pages/info/schedule_page.dart index 32417d90..d8cf3f68 100644 --- a/lib/pages/info/schedule_page.dart +++ b/lib/pages/info/schedule_page.dart @@ -101,7 +101,7 @@ class SchedulePageState extends State default: return CustomScrollView( slivers: [ - for (ScheduleData value in scheduleDataList) + for (final ScheduleData value in scheduleDataList) ..._scheduleItem(value), ], ); diff --git a/lib/pages/leave/leave_apply_page.dart b/lib/pages/leave/leave_apply_page.dart index 2d0cdf85..925d0c3b 100644 --- a/lib/pages/leave/leave_apply_page.dart +++ b/lib/pages/leave/leave_apply_page.dart @@ -718,7 +718,7 @@ class LeaveApplyPageState extends State text: '${ap.leaveDateAndSection}:\n', style: const TextStyle(fontWeight: FontWeight.bold), ), - for (Day day in days) TextSpan(text: '$day\n'), + for (final Day day in days) TextSpan(text: '$day\n'), TextSpan( text: '${ap.leaveProof}:' '${image == null ? ap.none : ''}\n', diff --git a/lib/pages/leave/leave_record_page.dart b/lib/pages/leave/leave_record_page.dart index 6b789d2e..89b26b71 100644 --- a/lib/pages/leave/leave_record_page.dart +++ b/lib/pages/leave/leave_record_page.dart @@ -203,8 +203,8 @@ class LeaveRecordPageState extends State ), children: [ leaveTitle, - for (Leave leave in leaveData!.leaves) - _leaveBorder(leave, leaveData!.timeCodes) + for (final Leave leave in leaveData!.leaves) + _leaveBorder(leave, leaveData!.timeCodes), ], ), ), diff --git a/lib/pages/login_page.dart b/lib/pages/login_page.dart index d80beece..4eb5108a 100644 --- a/lib/pages/login_page.dart +++ b/lib/pages/login_page.dart @@ -120,7 +120,7 @@ class LoginPageState extends State { ApUtils.showToast(context, ap.firstLoginHint); } }, - ) + ), ], ); } diff --git a/lib/pages/search_student_id_page.dart b/lib/pages/search_student_id_page.dart index 2a8830d6..39bc5ba6 100644 --- a/lib/pages/search_student_id_page.dart +++ b/lib/pages/search_student_id_page.dart @@ -106,7 +106,7 @@ class SearchStudentIdPageState extends State { FirebaseAnalyticsUtils.instance.logEvent('search_username_click'); _search(); }, - ) + ), ], ); } diff --git a/lib/pages/study/calculate_units_page.dart b/lib/pages/study/calculate_units_page.dart index ef8ccdc0..f4d9dbac 100644 --- a/lib/pages/study/calculate_units_page.dart +++ b/lib/pages/study/calculate_units_page.dart @@ -167,7 +167,7 @@ class CalculateUnitsPageState extends State children: [ const CircularProgressIndicator(), const SizedBox(height: 16.0), - Text(ap.calculating, style: _textBlueStyle()) + Text(ap.calculating, style: _textBlueStyle()), ], ), ); diff --git a/lib/utils/date_utils.dart b/lib/utils/date_utils.dart index df4e565d..b44ab1df 100644 --- a/lib/utils/date_utils.dart +++ b/lib/utils/date_utils.dart @@ -42,7 +42,7 @@ class CalendarDateUtils { 'Wed', 'Thu', 'Fri', - 'Sat' + 'Sat', ]; /// The list of days in a given month diff --git a/lib/widgets/flutter_calendar.dart b/lib/widgets/flutter_calendar.dart index 6628e215..083eec0b 100644 --- a/lib/widgets/flutter_calendar.dart +++ b/lib/widgets/flutter_calendar.dart @@ -245,7 +245,7 @@ class _CalendarState extends State { expanded: calendarGridView, isExpanded: isExpanded, ), - expansionButtonRow + expansionButtonRow, ], ); } diff --git a/lib/widgets/semester_picker.dart b/lib/widgets/semester_picker.dart index 4ce38303..6e672223 100644 --- a/lib/widgets/semester_picker.dart +++ b/lib/widgets/semester_picker.dart @@ -69,7 +69,7 @@ class SemesterPickerState extends State { Icon( ApIcon.keyboardArrowDown, color: ApTheme.of(context).semesterText, - ) + ), ], ), ), @@ -156,7 +156,9 @@ class SemesterPickerState extends State { context: context, builder: (BuildContext context) => SimpleOptionDialog( title: ApLocalizations.of(context).pickSemester, - items: [for (Semester item in semesterData.data) item.text], + items: [ + for (final Semester item in semesterData.data) item.text, + ], index: currentIndex, onSelected: (int index) { currentIndex = index;