callEngine method
Future<void>
callEngine(
- XFile file
)
Implementation
Future<void> callEngine(XFile file) async {
if (argument != null) {
/// Tính thời gian upload
isLoading.value = true;
final Stopwatch timer = Stopwatch();
timer.start();
var uploadRes = await uploadImageToS3Server(localFilePath: file.path);
timer.stop();
// Kết thúc
uploadRes.fold(
(l) {
isLoading(false);
status(
BaseStatus(
message: '${l.code.toString()}: ${l.details.toString()}',
state: AppState.customError,
),
);
showErrorDialog(true);
showRetake(true);
},
(r) async {
if (r.level == 'info' && r.filePath != null) {
await callEngineImpl(
localFilePath: file.path,
serverFilePath: r.filePath!,
timeAppUpload: timer.elapsedMilliseconds / 1000,
);
}
/// warning
else if (r.level == 'warning') {
cacheValidationModel['localFilePath'] = file.path;
cacheValidationModel['serverFilePath'] = r.filePath;
cacheValidationModel['timeAppUpload'] =
timer.elapsedMilliseconds / 1000;
isLoading(false);
showRetake(false);
status(
BaseStatus(
message: r.message ?? 'Warning',
state: AppState.warning,
),
);
}
/// error
else {
isLoading(false);
status(BaseStatus(message: null, state: AppState.idle));
showRetake(true);
}
},
);
}
}