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;
  }
相关推荐
君赏15 小时前
棉宇宙 Flutter 热更新是如何落地的
flutter
恋猫de小郭16 小时前
AndroidX 新增 Security State ,支持可编程的系统安全状态查询
android·前端·flutter
zihan51817 小时前
自己做软件日记9/21 得到了一个良好的文件结构框架
后端·flutter·前端框架·android studio
ZFJ_张福杰2 天前
【Flutter】Flutter 中有哪些耗时操作?从 UI 卡顿到 Isolate 性能优化
flutter·性能优化·卡顿·isolate
sakiko_2 天前
Flutter:Dart学习笔记1:基础UI组件等
flutter
9765033352 天前
iOS 上架 4.3a 被拒【uniapp专讲】
flutter·ios·objective-c·uniapp·swift
传奇开心果编程2 天前
【Flutter入门练中学】第2课:布局系统
学习·flutter·ui
君赏3 天前
FlutterPatch:把 Shorebird 热更新的控制面搬回自己服务器
flutter
用户2181697049303 天前
Flutter tootip 轻量级提示
flutter
用户2181697049303 天前
Flutter 拖拽 Draggable DragTarget
flutter