Commit 3be2694acf6dda5f1fa5960965876de86d25cb76

Authored by wdn127929
1 parent 41b89d59

裁剪图片 计算图片宽高测试代码费时间,注释

... ... @@ -4,6 +4,7 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
// {
// "name": "Flutter",
// "type": "dart",
... ...
buildscript {
// ext.kotlin_version = '1.3.50'
ext.kotlin_version = '1.6.20'
// ext.kotlin_version = '1.5.20'
// ext.kotlin_version = '1.6.21'
// ext.kotlin_version = '1.5.20'
... ... @@ -17,11 +19,13 @@ maven{
}
// maven { url 'https://maven.aliyun.com/repository/google' }
// maven { url 'https://maven.aliyun.com/repository/jcenter' }
maven { url 'https://maven.aliyun.com/repository/google' }
maven { url 'https://maven.aliyun.com/repository/jcenter' }
// maven { url 'http://maven.aliyun.com/nexus/content/groups/public' }
maven {url 'https://developer.huawei.com/repo/'}
}
dependencies {
... ... @@ -44,8 +48,8 @@ maven{
}
// maven { url 'https://maven.aliyun.com/repository/google' }
// maven { url 'https://maven.aliyun.com/repository/jcenter' }
maven { url 'https://maven.aliyun.com/repository/google' }
maven { url 'https://maven.aliyun.com/repository/jcenter' }
// maven { url 'http://maven.aliyun.com/nexus/content/groups/public' }
maven {url 'https://developer.huawei.com/repo/'}
... ...
... ... @@ -47,6 +47,8 @@ class _CouponPosterPageState extends State<CouponPosterPage> {
// 全局key
final GlobalKey _rootWidgetKey = GlobalKey();
final GlobalKey globalKey = GlobalKey();
@override
void initState() {
// TODO: implement initState
... ... @@ -74,9 +76,11 @@ class _CouponPosterPageState extends State<CouponPosterPage> {
/// 截图
Future<Uint8List> _capturePng(
GlobalKey globalKey, {
double pixelRatio = 2.0, //截屏的图片与原图的比例
}) async {
GlobalKey globalKey,
// {
// double pixelRatio = 2.0, //截屏的图片与原图的比例
// }
) async {
try {
RenderRepaintBoundary boundary =
globalKey.currentContext?.findRenderObject() as RenderRepaintBoundary;
... ... @@ -142,6 +146,12 @@ class _CouponPosterPageState extends State<CouponPosterPage> {
// title = "${widget.couponSunModel.aname}";
name = "${widget.couponSunModel.aname}";
}
double _height = w(64);
Future.delayed(Duration(milliseconds: 200)).then((e) {
_height = globalKey.currentContext.size.height;
debugPrint('Height is ${context.size.height}');
setState(() {});
});
return Scaffold(
appBar: SystemAppBar('优惠券详情'),
... ... @@ -161,24 +171,26 @@ class _CouponPosterPageState extends State<CouponPosterPage> {
Stack(
clipBehavior: Clip.none,
children: [
// user.sellerimage != null &&
// user.sellerimage != ''
// ? CachedNetworkImage(
// imageUrl: user.sellerimage,
// width: double.infinity,
// height: w(280),
// fit: BoxFit.cover,
// )
// :
Image.asset(
Utils.getImgPath('no_image'),
width: double.infinity,
height: w(280),
fit: BoxFit.cover,
),
user.sellerimage != null &&
user.sellerimage != ''
? CachedNetworkImage(
imageUrl: user.sellerimage,
width: double.infinity,
height: w(280),
fit: BoxFit.cover,
)
: Image.asset(
Utils.getImgPath('no_image'),
width: double.infinity,
height: w(280),
fit: BoxFit.cover,
),
Positioned(
bottom: -w(64),
bottom: _height / 2,
child: Container(
key: globalKey,
width: ScreenUtil().screenWidth -
w(20) * 2,
// width: double.infinity,
// height: w(128),
padding: EdgeInsets.symmetric(
... ... @@ -193,6 +205,8 @@ class _CouponPosterPageState extends State<CouponPosterPage> {
borderRadius:
BorderRadius.circular(r(8))),
child: Column(
// mainAxisSize: ,
// main
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
... ...
... ... @@ -1718,14 +1718,14 @@ class Utils {
afterImg = await yourFile.readAsBytes();
}
IMG.Image decodedImage = IMG.decodeImage(data);
print(decodedImage.width);
print(decodedImage.height);
IMG.Image decodedImageafterImg = IMG.decodeImage(afterImg);
print(decodedImageafterImg.width);
print(decodedImageafterImg.height);
debugPrint("newnenwnewnnwen图片的大小:${size(afterImg.length)}");
// IMG.Image decodedImage = IMG.decodeImage(data);
// print(decodedImage.width);
// print(decodedImage.height);
// IMG.Image decodedImageafterImg = IMG.decodeImage(afterImg);
// print(decodedImageafterImg.width);
// print(decodedImageafterImg.height);
// debugPrint("newnenwnewnnwen图片的大小:${size(afterImg.length)}");
return afterImg;
}
... ...
... ... @@ -121,7 +121,7 @@ dependencies:
# 获取设备信息
device_info: ^2.0.3
# flutter_sms: ^2.1.1
flutter_sms: ^2.3.2
flutter_sms: ^2.3.3
# 获取通讯录
... ... @@ -219,6 +219,7 @@ dependencies:
image_gallery_saver: ^2.0.3
flutter_image_compress: ^1.1.3
image: ^4.0.15
# image_cropper: ^3.0.1
image_cropper: ^4.0.1
pin_code_fields: ^7.4.0
# 二维码扫描
... ... @@ -239,6 +240,7 @@ dependencies:
# 生成excel
excel: ^3.0.0
# workmanager: ^0.5.1
... ...