mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-12 11:24:08 +00:00
flutter 3.7 compatibility responsive view beautiful progress bar select file in treeview downlading and downloaded page
34 lines
697 B
Dart
34 lines
697 B
Dart
import 'dart:async';
|
|
|
|
import 'package:get/get.dart';
|
|
|
|
import '../../api/api.dart';
|
|
import '../../api/model/task.dart';
|
|
|
|
class DownloadingController extends GetxController {
|
|
final tasks = <Task>[].obs;
|
|
|
|
late final Timer _timer;
|
|
|
|
@override
|
|
void onInit() async {
|
|
super.onInit();
|
|
await getTasksState();
|
|
_timer = Timer.periodic(const Duration(milliseconds: 1000), (timer) async {
|
|
// debugPrint('timer${DateTime.now()}');
|
|
await getTasksState();
|
|
});
|
|
}
|
|
|
|
@override
|
|
void onClose() {
|
|
super.onClose();
|
|
_timer.cancel();
|
|
}
|
|
|
|
getTasksState() async {
|
|
tasks.value = await getTasks(
|
|
[Status.ready, Status.running, Status.pause, Status.error]);
|
|
}
|
|
}
|