clickPhoto method
dynamic
clickPhoto()
Implementation
clickPhoto() async {
ImagePicker imagePicker = ImagePicker();
final XFile? image =
await imagePicker.pickImage(source: ImageSource.gallery);
if (image != null) {
// 判断是否为支持的图片类型
bool isImage = supportedImageExtensions
.any((extension) => image.path.endsWith(extension));
if (isImage) {
list.add(File(image.path));
if (list.length >= maxlength + 1) {
list.removeAt(0);
}
callbackImage(list.where((e) => e.path.isNotEmpty).toList());
} else {
BaseToast.showError("请选择正确的图片类型");
}
}
}