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

在 style.xml中添加style

<!-- 解决图片裁剪顶状态栏核心主题 -->
    <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>

清单文件中配置

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

代码配置

/*
  * 调起裁剪图片
  * */
  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;
  }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值