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;
}
}

我把完整的代码放在这里:

https://controlc.com/9590e7b1

这里是调试控制台中的错误 调试控制台

debug console

推荐答案

看起来您正在使用ImageCropper包.https://github.com/hnvn/flutter_image_cropper/blob/master/lib/src/cropper.dart#L61出现错误,因为该方法不是静电,因此您必须创建类的新实例才能访问它

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;
}
}

Flutter相关问答推荐

Flutter日期和时间 Select 器未显示

滚动时应用栏 colored颜色 更改Flutter

类型flatter doctor get zsh:未找到命令:macO中flatter

Riverpod生成器和生成util类

ShaderMask上的文本渐变问题

Flutter Go路由深度链接不按预期工作

Android Emulator冻结,但在调整窗口大小时解冻

来自FutureProvider的数据只打印两个不同的变量,它们对一个实例只有一次相同的值,为什么?

为什么要在值列表中两次放入空安全性

IsScrollable为True时如何删除Flutter 选项卡栏左侧填充

从.gitignore中排除.fvm/fvm_config.json

无法将新文物与Flutter 项目集成在一起

Riverpod中stateNotiferProvider和notifierProvider的区别

Flutter - 我需要显示文本,但应用程序不需要

MediaQuery 在不同手机上不一致

如何让小部件根据小部件的大小构建不同的布局?

应用程序和应用程序内的 webview 之间的单点登录

在 Flutter 中使用 HardwareKeyboard 时所有键都没有响应

.info/connected 这两个代码之间有什么区别吗?

Flutter ListView builder 未使用新数据更新