flutter image_cropper截图控件布局顶到状态栏中问题

在 style.xml中添加style

dart 复制代码
<!-- 解决图片裁剪顶状态栏核心主题 -->
    <style name="UCropTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="android:windowNoTitle">true</item>
        <item name="android:windowFullscreen">false</item>
        <item name="android:fitsSystemWindows">true</item>
        <item name="android:windowDrawsSystemBarBackgrounds">true</item>
        <item name="android:statusBarColor">#FFE50F</item>
        <item name="android:windowLightStatusBar">true</item>

    </style>

清单文件中配置

xml 复制代码
<activity
            android:name="com.yalantis.ucrop.UCropActivity"
            android:screenOrientation="portrait"
            android:windowSoftInputMode="adjustResize"
            android:theme="@style/UCropTheme"
            tools:replace="android:theme"
            android:exported="false"/>

代码配置

dart 复制代码
/*
  * 调起裁剪图片
  * */
  Future<String> cropImage(String imagePath) async {
    Completer<String> completer = Completer<String>();
    if (imagePath.isNotEmpty) {
      final croppedImage = await ImageCropper().cropImage(
        sourcePath: imagePath,
        aspectRatio: CropAspectRatio(ratioX: 1, ratioY: 1), // 设置特定比率
        compressQuality: 100, // 图像质量
        maxWidth: 800, // 最大宽度
        maxHeight: 800, // 最大高度
        uiSettings: [
          AndroidUiSettings(
            toolbarTitle: '裁剪',
            toolbarColor: Colors.white,//标题背景色
          //  statusBarLight: false,
            toolbarWidgetColor: Colors.black,//按钮、标题颜色
            initAspectRatio: CropAspectRatioPreset.original,
            lockAspectRatio: false,
            aspectRatioPresets: [
              CropAspectRatioPreset.original,
              CropAspectRatioPreset.square,
              CropAspectRatioPresetCustom(),
            ],
          ),
          IOSUiSettings(
              title: '裁剪'
          )
        ],
      );

      if (croppedImage != null) {
        print('剪切后的图片路径:${croppedImage.path}');
        completer.complete(croppedImage.path);
      }else{
        completer.complete('');
      }
    }
    return completer.future;
  }
相关推荐
风华圆舞1 天前
在 Flutter 鸿蒙项目里接入语音识别的完整思路
flutter·语音识别·harmonyos
风华圆舞1 天前
鸿蒙 + Flutter 下如何让 HarmonyOS 能力真正服务于 AI 体验
人工智能·flutter·harmonyos
BreezeDove1 天前
【Android】Flutter3.35项目启动超时问题
android·flutter
风华圆舞1 天前
鸿蒙 MICROPHONE 权限在 Flutter 项目里怎么处理
flutter·华为·harmonyos
愚者Pro2 天前
切换本地 Flutter SDK 版本
flutter
TT_Close2 天前
别再复制旧 Flutter 工程了,真正拖慢你的不是业务代码
flutter·npm·visual studio code
风华圆舞2 天前
鸿蒙 + Flutter 下 AI 助手为什么要支持流式输出
人工智能·flutter·harmonyos
风华圆舞2 天前
鸿蒙 + Flutter 下 AI 页面的状态协同设计
人工智能·flutter·harmonyos
风华圆舞2 天前
鸿蒙语音播报功能 的 Flutter 侧封装思路
flutter·华为·harmonyos
brycegao3212 天前
Flutter 国际化富文本解决方案:基于双层占位符的轻量化图文混排方案
flutter·国际化·i18n·富文本·rtl·移动端工程架构