Skip to content

Commit

Permalink
feat: remove tuple package, use record syntax for get questions api
Browse files Browse the repository at this point in the history
  • Loading branch information
JingYiJun committed Aug 8, 2024
1 parent 91ed50a commit 4883bc6
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
4 changes: 2 additions & 2 deletions lib/page/forum/quiz.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ class OTQuizWidgetState extends State<OTQuizWidget> {
onPressed: () async {
final result = await ForumRepository.getInstance()
.getPostRegisterQuestions();
questions = result.item1;
version = result.item2;
questions = result.$1;
version = result.$2;
if (questions != null) {
indexes =
List.generate(questions!.length, (index) => index);
Expand Down
7 changes: 3 additions & 4 deletions lib/repository/forum/forum_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ import 'package:dan_xi/util/io/user_agent_interceptor.dart';
import 'package:dan_xi/util/platform_universal.dart';
import 'package:dan_xi/widget/libraries/paged_listview.dart';
import 'package:dio/dio.dart';
import 'package:tuple/tuple.dart';

/// The repository for forum.
///
Expand Down Expand Up @@ -834,16 +833,16 @@ class ForumRepository extends BaseRepositoryWithDio {
return resp.statusCode;
}

Future<Tuple2<List<QuizQuestion>?, int>> getPostRegisterQuestions() async {
Future<(List<QuizQuestion>?, int)> getPostRegisterQuestions() async {
final Response<Map<String, dynamic>> response = await dio.get(
"$_BASE_AUTH_URL/register/questions",
options: Options(headers: _tokenHeader));
final questionList = response.data?["questions"]
final List<QuizQuestion>? questionList = response.data?["questions"]
.map((e) => QuizQuestion.fromJson(e))
.toList()
.cast<QuizQuestion>();
final int version = response.data?["version"];
return Tuple2(questionList, version);
return (questionList, version);
}

// Empty list means all-correct
Expand Down
2 changes: 1 addition & 1 deletion pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1890,7 +1890,7 @@ packages:
source: hosted
version: "0.2.3"
tuple:
dependency: "direct main"
dependency: transitive
description:
name: tuple
sha256: a97ce2013f240b2f3807bcbaf218765b6f301c3eff91092bcfa23a039e7dd151
Expand Down
9 changes: 4 additions & 5 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: dan_xi
description: Maybe the best all-rounded service app for Fudan University students.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
publish_to: "none" # Remove this line if you wish to publish to pub.dev
version: 1.4.4+341

environment:
sdk: '>=3.0.0'
sdk: ">=3.0.0"

dependencies:
flutter:
Expand Down Expand Up @@ -70,8 +70,8 @@ dependencies:
file_picker: ^8.0.6
cached_network_image: ^3.2.1
flutter_typeahead: ^5.2.0
collection: '>=1.15.0 <2.0.0'
meta: '>=1.3.0 <2.0.0'
collection: ">=1.15.0 <2.0.0"
meta: ">=1.3.0 <2.0.0"
flutter_layout_grid: ^2.0.1
flutter_js: ^0.8.0
flutter_math_fork: ^0.7.2
Expand Down Expand Up @@ -108,7 +108,6 @@ dependencies:
html: any
cookie_jar: any
ffi: any
tuple: ^2.0.2

dependency_overrides:
intl: ^0.19.0
Expand Down

0 comments on commit 4883bc6

Please sign in to comment.