class ImagesCropper {
static Future<File?> cropImage(XFile file) async {
final File? croppedImage = await ImageCropper.cropImage(
sourcePath: file.path,
aspectRatioPresets:
Platform.isAndroid ? crossAspectRatioAndroid : crossAspectRatioIos,
androidUiSettings: androidUiSettings,
iosUiSettings: iosUiSettings,
);
return croppedImage;
}
}
Run Code Online (Sandbox Code Playgroud)
我把完整的代码放在这里:
这是调试控制台中的错误调试控制台
Lig*_*ing 20
看起来您正在使用 ImageCropper 包。https://github.com/hnvn/flutter_image_cropper/blob/master/lib/src/cropper.dart#L61出现错误,因为该方法不是静态的,因此您必须创建该类的新实例才能访问它
await ImageCropper().cropImage...
Run Code Online (Sandbox Code Playgroud)
完整的代码更正如下
class ImagesCropper {
static Future<File?> cropImage(XFile file) async {
final File? croppedImage = await ImageCropper().cropImage(
sourcePath: file.path,
aspectRatioPresets:
Platform.isAndroid ? crossAspectRatioAndroid : crossAspectRatioIos,
androidUiSettings: androidUiSettings,
iosUiSettings: iosUiSettings,
);
return croppedImage;
}
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
6416 次 |
最近记录: |