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;
  }
相关推荐
程序员老刘6 小时前
跨平台开发地图:大厂统一底层,五月框架大乱斗谁在干实事?| 2026年5月
flutter·客户端
环信即时通讯云8 小时前
环信Flutter UIKit适配鸿蒙实战指南
flutter·华为·harmonyos
用户5368221001810 小时前
flutter学习笔记 - Dart基本语法(一)
flutter
用户游民11 小时前
Flutter Provider原理以及用法
前端·flutter
qq_140303414413 小时前
flutter
flutter
程序员老刘1 天前
为什么AI不会淘汰Flutter,反而让它更吃香了
flutter·ai编程·客户端
蝎子莱莱爱打怪1 天前
我花两年业余时间做了个IM系统,然后呢😂??
后端·flutter·面试
Swuagg2 天前
Flutter EventBus 架构设计:基于 Stream 的事件总线实现与实践
flutter·eventbus·事件总线