Skip to content

Commit

Permalink
chore: code tune for dart 2.19 lint
Browse files Browse the repository at this point in the history
  • Loading branch information
abc873693 committed Jan 6, 2024
1 parent 94944cf commit 4eb7b87
Show file tree
Hide file tree
Showing 22 changed files with 68 additions and 61 deletions.
6 changes: 3 additions & 3 deletions lib/api/ap_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class WebApHelper {
data: <String, String>{
'uid': username,
'pwd': password,
'etxt_code': captchaCode
'etxt_code': captchaCode,
},
options: Options(contentType: 'application/x-www-form-urlencoded'),
);
Expand Down Expand Up @@ -273,7 +273,7 @@ class WebApHelper {
'https://leave.nkust.edu.tw/SkyDir.aspx',
queryParameters: <String, dynamic>{
'u': skyDirectData['uid'],
'r': skyDirectData['ls_randnum']
'r': skyDirectData['ls_randnum'],
},
options: Options(
followRedirects: false,
Expand Down Expand Up @@ -546,7 +546,7 @@ class WebApHelper {
'ag302_01',
<String, String>{
'yms_yms': '$years#$semesterValue',
'cmp_area_id': cmpAreaId
'cmp_area_id': cmpAreaId,
},
);

Expand Down
8 changes: 4 additions & 4 deletions lib/api/bus_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class BusEncrypt {
'c': i,
'd': j,
'e': k,
'f': passwordMD5
'f': passwordMD5,
},
);
}
Expand Down Expand Up @@ -222,7 +222,7 @@ class BusHelper {
'n': busEncryptObject.loginEncrypt(
Helper.username!,
Helper.password!,
)
),
},
options: Options(contentType: Headers.formUrlEncodedContentType),
);
Expand Down Expand Up @@ -262,7 +262,7 @@ class BusHelper {
'operation': '全部',
'page': 1,
'start': 0,
'limit': 90
'limit': 90,
};
options = Options(contentType: Headers.formUrlEncodedContentType);
} else {
Expand All @@ -277,7 +277,7 @@ class BusHelper {
'operation': '全部',
'page': 1,
'start': 0,
'limit': 90
'limit': 90,
},
);
options = buildCacheOptions(
Expand Down
2 changes: 1 addition & 1 deletion lib/api/leave_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
12 changes: 7 additions & 5 deletions lib/api/mobile_nkust_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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?;
Expand Down Expand Up @@ -167,7 +167,9 @@ class MobileNkustHelper {
if (data != null) {
if (otherRequestUrl != null) {
final Map<String, dynamic> requestData = <String, dynamic>{
'__RequestVerificationToken': MobileNkustParser.getCSRF(response.data)
'__RequestVerificationToken': MobileNkustParser.getCSRF(
response.data,
),
};
requestData.addAll(data);

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -514,7 +516,7 @@ class MobileNkustHelper {
'Referer': homeUrl,
},
otherRequestHeader: <String, String>{
'Referer': busViolationRecordsPageUrl
'Referer': busViolationRecordsPageUrl,
},
);
// not pay request
Expand Down
2 changes: 1 addition & 1 deletion lib/api/nkust_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class NKUSTHelper {
'data': <String, dynamic>{
'page': page + 1,
'notification': acadData,
}
},
});
}
}
53 changes: 28 additions & 25 deletions lib/api/parser/ap_parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -111,7 +114,7 @@ class WebApParser {
'className': null,
'id': null,
'name': null,
'pictureUrl': null
'pictureUrl': null,
};
final Document document = parse(html);
final List<Element> tdElements = document.getElementsByTagName('td');
Expand Down Expand Up @@ -165,8 +168,8 @@ class WebApParser {
'default': <String, dynamic>{
'year': '108',
'value': '2',
'text': '108學年第二學期(Parse失敗)'
}
'text': '108學年第二學期(Parse失敗)',
},
};
final Document document = parse(html);

Expand All @@ -181,15 +184,15 @@ class WebApParser {
<String, dynamic>{
'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) {
//set default
data['default'] = <String, dynamic>{
'year': ymsElements[i].attributes['value']!.split('#')[0],
'value': ymsElements[i].attributes['value']!.split('#')[1],
'text': ymsElements[i].text
'text': ymsElements[i].text,
};
}
}
Expand All @@ -205,8 +208,8 @@ class WebApParser {
'conduct': null,
'classRank': null,
'departmentRank': null,
'average': null
}
'average': null,
},
};
//detail part
try {
Expand All @@ -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
Expand Down Expand Up @@ -290,7 +293,7 @@ class WebApParser {
'location': <String, dynamic>{
'building': '',
'room': td[10].text,
}
},
},
);
}
Expand Down Expand Up @@ -369,7 +372,7 @@ class WebApParser {
'Thursday',
'Friday',
'Saturday',
'Sunday'
'Sunday',
];
try {
for (int weekdayIndex = 0;
Expand Down Expand Up @@ -428,7 +431,7 @@ class WebApParser {

Map<String, dynamic> midtermAlertsParser(String? html) {
final Map<String, dynamic> data = <String, dynamic>{
'courses': <Map<String, dynamic>>[]
'courses': <Map<String, dynamic>>[],
};

final Document document = parse(html);
Expand All @@ -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,
},
);
}
Expand All @@ -464,7 +467,7 @@ class WebApParser {

Map<String, dynamic> rewardAndPenaltyParser(String? html) {
final Map<String, dynamic> data = <String, dynamic>{
'data': <Map<String, dynamic>>[]
'data': <Map<String, dynamic>>[],
};

final Document document = parse(html);
Expand All @@ -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,
},
);
}
Expand All @@ -501,7 +504,7 @@ class WebApParser {

Map<String, dynamic> roomListParser(String? html) {
final Map<String, dynamic> data = <String, dynamic>{
'data': <Map<String, dynamic>>[]
'data': <Map<String, dynamic>>[],
};

final Document document = parse(html);
Expand All @@ -512,7 +515,7 @@ class WebApParser {
(data['data'] as List<Map<String, dynamic>>).add(
<String, dynamic>{
'roomName': table[i].text,
'roomId': table[i].attributes['value'] ?? '0035'
'roomId': table[i].attributes['value'] ?? '0035',
},
);
}
Expand Down Expand Up @@ -543,10 +546,10 @@ class WebApParser {
'Thursday': <Map<String, dynamic>>[],
'Friday': <Map<String, dynamic>>[],
'Saturday': <Map<String, dynamic>>[],
'Sunday': <Map<String, dynamic>>[]
'Sunday': <Map<String, dynamic>>[],
},
'_temp_time': <Map<String, dynamic>>{},
'timeCodes': <Map<String, dynamic>>[]
'timeCodes': <Map<String, dynamic>>[],
};

final Map<String, dynamic> courseTable =
Expand Down Expand Up @@ -584,8 +587,8 @@ class WebApParser {
'sectionTimes': <Map<String, dynamic>>[],
'location': null,
'instructors':
td[10].text.replaceAll(specialSpace, '').split(',')
}
td[10].text.replaceAll(specialSpace, '').split(','),
},
},
);
}
Expand Down Expand Up @@ -620,7 +623,7 @@ class WebApParser {
'Thursday',
'Friday',
'Saturday',
'Sunday'
'Sunday',
];
String tmpCourseName = '';
try {
Expand Down Expand Up @@ -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) {
Expand All @@ -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, '')
Expand Down Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion lib/api/parser/bus_parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Map<String, dynamic> busTimeTableParser(
'specialTrain': data['data'][i]['SpecialTrain'],
'description': data['data'][i]['SpecialTrainRemark'],
'homeCharteredBus': false,
'cancelKey': ''
'cancelKey': '',
};
if (temp['SpecialTrain'] == '1') {
temp['homeCharteredBus'] = true;
Expand Down
4 changes: 2 additions & 2 deletions lib/api/parser/leave_parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Map<String, dynamic> leaveQueryParser(String? html) {
if (tableDom.isEmpty) {
return <String, dynamic>{
'data': <Map<String, dynamic>>[],
'timeCodes': <String>[]
'timeCodes': <String>[],
};
}
final List<Element> trDom = tableDom[0].getElementsByTagName('tr');
Expand Down Expand Up @@ -123,7 +123,7 @@ Map<String, dynamic>? leaveSubmitInfoParser(String? html) {
'10',
'11',
'12',
'13'
'13',
];
}
//LeaveType generate part.
Expand Down
2 changes: 1 addition & 1 deletion lib/api/parser/mobile_nkust_parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class MobileNkustParser {
'location': <String, dynamic>{
'building': '',
'room': course['CourseRoom'] ?? '',
}
},
};
final bool hasMorning = periodTimeJson[0]['PeriodName'] == 'M';
final List<dynamic> courseWeekPeriod =
Expand Down
4 changes: 2 additions & 2 deletions lib/pages/bus/bus_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class BusPageState extends State<BusPage> with SingleTickerProviderStateMixin {
final List<Widget> _children = <Widget>[
BusReservePage(),
BusReservationsPage(),
BusViolationRecordsPage()
BusViolationRecordsPage(),
];

Future<bool>? _login;
Expand Down Expand Up @@ -73,7 +73,7 @@ class BusPageState extends State<BusPage> with SingleTickerProviderStateMixin {
const BusRulePage(),
);
},
)
),
],
elevation: (_currentIndex == 2) ? 0.0 : null,
),
Expand Down
Loading

0 comments on commit 4eb7b87

Please sign in to comment.