import 'package:get/get.dart'; import '../../../core/utils/upload_oss.dart'; import '../db/sqflite_api.dart'; class MeetingUploadService extends GetxService { RxInt meetingId = 0.obs; RxDouble uploadProgress = 0.0.obs; RxList uploadList = [].obs; bool _isUpload = false; int _handled = 0; @override void onInit() { super.onInit(); _getUploadList(); } void _getUploadList() {} void addUpload(int id, String filePath, String rootDir) async { uploadList.add({ 'id': id, 'filepath': filePath, 'rootdir': rootDir, 'audiourl': '', }); if (_isUpload) return; _isUpload = true; _handled = 0; while (_handled < uploadList.length) { Map element = uploadList[_handled]; _handled++; if (element['audiourl'].isNotEmpty) { meetingId.value = element['id']; final audiourl = await UploadOss.upload( filepath: element['filepath'], rootDir: element['rootdir'], ); await SqfliteApi.editMeetingTitle( element['id'], {'audiourl': audiourl}, ); element['audiourl'] = audiourl; } } _isUpload = false; } }