Skip to content

Commit

Permalink
Migrate: Remove must.dart
Browse files Browse the repository at this point in the history
  • Loading branch information
ntut-xuan committed Feb 9, 2024
1 parent 0d2b1c0 commit f10d450
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/src/connector/course_connector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import 'package:flutter_app/src/model/course/course_syllabus.dart';
import 'package:html/dom.dart';
import 'package:html/parser.dart';

import '../util/must.dart';

enum CourseConnectorStatus { loginSuccess, loginFail, unknownError }

class CourseConnector {
Expand Down Expand Up @@ -318,8 +316,10 @@ class CourseConnector {
for (int i = 0; i < nodes.length; i++) {
node = nodes[i];
var href = node.attributes["href"];
Must.notNullOrEmpty(href, "href");
Map<String, String> code = Uri.parse(href!).queryParameters;
if(href == null || href.isEmpty){
throw Exception("getDivisionList: href is null or empty.");
}
Map<String, String> code = Uri.parse(href).queryParameters;
resultList.add({"name": node.text, "code": code});
}
return resultList;
Expand Down Expand Up @@ -351,7 +351,9 @@ class CourseConnector {
for (int i = 0; i < nodes.length; i++) {
node = nodes[i];
var href = node.attributes["href"];
Must.notNullOrEmpty(href, "href");
if(href == null || href.isEmpty){
throw Exception("getDepartmentList: href is null or empty.");
}
Map<String, String> code = Uri.parse(href!).queryParameters;
String name = node.text.replaceAll(RegExp("[ |s]"), "");
resultList.add({"name": name, "code": code});
Expand Down

0 comments on commit f10d450

Please sign in to comment.