【发布时间】:2021-12-21 15:59:48
【问题描述】:
这是我的拍照方法:
handleTakePhoto() async {
Navigator.pop(context);
XFile? file = await ImagePicker()
.pickImage(source: ImageSource.camera, maxWidth: 960, maxHeight: 675);
setState(() {
this.file = file;
bytes = File(file!.path).readAsBytesSync();
});
}
虽然这是用来拍摄视频的:
handleTakeVideo() async {
Navigator.pop(context);
XFile? file = await ImagePicker()
.pickVideo(source: ImageSource.camera, maxDuration: const Duration(seconds: 10));
setState(() {
this.file = file;
bytes = File(file!.path).readAsBytesSync();
});
}
如您所见,它们实际上是相同的,但稍后在我的程序中,我需要知道文件是图像还是视频。我该怎么办?
【问题讨论】:
标签: flutter dart flutter-dependencies imagepicker flutter-image