addVideo method
Implementation
Future<void> addVideo() async {
if (isNotSelectedImageYet()) {
try {
final XFile? video =
await _picker.pickVideo(source: ImageSource.gallery);
if (video != null) {
var fileWithStatus = AmityFileInfoWithUploadStatus();
amityVideo = fileWithStatus;
amityVideo!.file = File(video.path);
notifyListeners();
await AmityCoreClient.newFileRepository()
.video(File(video.path))
.upload()
.then((value) {
var fileInfo = value as AmityUploadComplete;
amityVideo!.addFile(fileInfo.getFile);
log(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>${fileInfo.getFile.fileId}");
notifyListeners();
}).onError((error, stackTrace) async {
log("error: $error");
await AmityDialog().showAlertErrorDialog(
title: "Error!", message: error.toString());
});
} else {
log("error: video is null");
await AmityDialog().showAlertErrorDialog(
title: "Error!", message: "error: video is null");
}
} catch (error) {
log("error: $error");
await AmityDialog()
.showAlertErrorDialog(title: "Error!", message: error.toString());
}
}
}