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;
  }
相关推荐
SoaringHeart13 小时前
Flutter最佳实践:Web项目中文字体首次加载乱码问题解决
前端·flutter
程序员老刘13 小时前
Flutter 3.47 更新要点:Material 正式分家,老项目先别急着更新
flutter·ai编程·客户端
stringwu19 小时前
Flutter Generative UI 深度架构剖析与官方 SDK 实战
flutter
唐诺21 小时前
flutter StreamController 完全使用指南
flutter·stream
GitLqr1 天前
玩转 Flutter 中的 Stack 与 Positioned:解决 UI 重叠问题的实战指南
flutter·面试·全栈
唔662 天前
flutter web iOS 在浏览器加载中文慢的问题
前端·flutter·ios
恋猫de小郭2 天前
Jetpack Compose 8 月版正式发布,核心模块 1.12
android·前端·flutter
梦想的颜色3 天前
AI 时代小白 VibeCoding 做 APP:UniApp(含 Uni‑X)、Flutter 与 React Native+Expo全维度技术选型对比指南
flutter·react native·app·uniapp·vibecoding·unippx·app产品
坚果的博客3 天前
Flutter-OH 3.44.9-dev 悄然上线|首个 OpenHarmony Canary 预览版上线
flutter