Commit 3be2694acf6dda5f1fa5960965876de86d25cb76

Authored by wdn127929
1 parent 41b89d59

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

@@ -4,6 +4,7 @@ @@ -4,6 +4,7 @@
4 // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 4 // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 "version": "0.2.0", 5 "version": "0.2.0",
6 "configurations": [ 6 "configurations": [
  7 +
7 // { 8 // {
8 // "name": "Flutter", 9 // "name": "Flutter",
9 // "type": "dart", 10 // "type": "dart",
1 buildscript { 1 buildscript {
2 // ext.kotlin_version = '1.3.50' 2 // ext.kotlin_version = '1.3.50'
3 ext.kotlin_version = '1.6.20' 3 ext.kotlin_version = '1.6.20'
  4 +
  5 + // ext.kotlin_version = '1.5.20'
4 // ext.kotlin_version = '1.6.21' 6 // ext.kotlin_version = '1.6.21'
5 7
6 // ext.kotlin_version = '1.5.20' 8 // ext.kotlin_version = '1.5.20'
@@ -17,11 +19,13 @@ maven{ @@ -17,11 +19,13 @@ maven{
17 } 19 }
18 20
19 21
20 - // maven { url 'https://maven.aliyun.com/repository/google' }  
21 - // maven { url 'https://maven.aliyun.com/repository/jcenter' } 22 + maven { url 'https://maven.aliyun.com/repository/google' }
  23 + maven { url 'https://maven.aliyun.com/repository/jcenter' }
22 // maven { url 'http://maven.aliyun.com/nexus/content/groups/public' } 24 // maven { url 'http://maven.aliyun.com/nexus/content/groups/public' }
23 25
24 maven {url 'https://developer.huawei.com/repo/'} 26 maven {url 'https://developer.huawei.com/repo/'}
  27 +
  28 +
25 } 29 }
26 30
27 dependencies { 31 dependencies {
@@ -44,8 +48,8 @@ maven{ @@ -44,8 +48,8 @@ maven{
44 } 48 }
45 49
46 50
47 - // maven { url 'https://maven.aliyun.com/repository/google' }  
48 - // maven { url 'https://maven.aliyun.com/repository/jcenter' } 51 + maven { url 'https://maven.aliyun.com/repository/google' }
  52 + maven { url 'https://maven.aliyun.com/repository/jcenter' }
49 // maven { url 'http://maven.aliyun.com/nexus/content/groups/public' } 53 // maven { url 'http://maven.aliyun.com/nexus/content/groups/public' }
50 54
51 maven {url 'https://developer.huawei.com/repo/'} 55 maven {url 'https://developer.huawei.com/repo/'}
@@ -47,6 +47,8 @@ class _CouponPosterPageState extends State<CouponPosterPage> { @@ -47,6 +47,8 @@ class _CouponPosterPageState extends State<CouponPosterPage> {
47 // 全局key 47 // 全局key
48 final GlobalKey _rootWidgetKey = GlobalKey(); 48 final GlobalKey _rootWidgetKey = GlobalKey();
49 49
  50 + final GlobalKey globalKey = GlobalKey();
  51 +
50 @override 52 @override
51 void initState() { 53 void initState() {
52 // TODO: implement initState 54 // TODO: implement initState
@@ -74,9 +76,11 @@ class _CouponPosterPageState extends State<CouponPosterPage> { @@ -74,9 +76,11 @@ class _CouponPosterPageState extends State<CouponPosterPage> {
74 76
75 /// 截图 77 /// 截图
76 Future<Uint8List> _capturePng( 78 Future<Uint8List> _capturePng(
77 - GlobalKey globalKey, {  
78 - double pixelRatio = 2.0, //截屏的图片与原图的比例  
79 - }) async { 79 + GlobalKey globalKey,
  80 + // {
  81 + // double pixelRatio = 2.0, //截屏的图片与原图的比例
  82 + // }
  83 + ) async {
80 try { 84 try {
81 RenderRepaintBoundary boundary = 85 RenderRepaintBoundary boundary =
82 globalKey.currentContext?.findRenderObject() as RenderRepaintBoundary; 86 globalKey.currentContext?.findRenderObject() as RenderRepaintBoundary;
@@ -142,6 +146,12 @@ class _CouponPosterPageState extends State<CouponPosterPage> { @@ -142,6 +146,12 @@ class _CouponPosterPageState extends State<CouponPosterPage> {
142 // title = "${widget.couponSunModel.aname}"; 146 // title = "${widget.couponSunModel.aname}";
143 name = "${widget.couponSunModel.aname}"; 147 name = "${widget.couponSunModel.aname}";
144 } 148 }
  149 + double _height = w(64);
  150 + Future.delayed(Duration(milliseconds: 200)).then((e) {
  151 + _height = globalKey.currentContext.size.height;
  152 + debugPrint('Height is ${context.size.height}');
  153 + setState(() {});
  154 + });
145 155
146 return Scaffold( 156 return Scaffold(
147 appBar: SystemAppBar('优惠券详情'), 157 appBar: SystemAppBar('优惠券详情'),
@@ -161,24 +171,26 @@ class _CouponPosterPageState extends State<CouponPosterPage> { @@ -161,24 +171,26 @@ class _CouponPosterPageState extends State<CouponPosterPage> {
161 Stack( 171 Stack(
162 clipBehavior: Clip.none, 172 clipBehavior: Clip.none,
163 children: [ 173 children: [
164 - // user.sellerimage != null &&  
165 - // user.sellerimage != ''  
166 - // ? CachedNetworkImage(  
167 - // imageUrl: user.sellerimage,  
168 - // width: double.infinity,  
169 - // height: w(280),  
170 - // fit: BoxFit.cover,  
171 - // )  
172 - // :  
173 - Image.asset(  
174 - Utils.getImgPath('no_image'),  
175 - width: double.infinity,  
176 - height: w(280),  
177 - fit: BoxFit.cover,  
178 - ), 174 + user.sellerimage != null &&
  175 + user.sellerimage != ''
  176 + ? CachedNetworkImage(
  177 + imageUrl: user.sellerimage,
  178 + width: double.infinity,
  179 + height: w(280),
  180 + fit: BoxFit.cover,
  181 + )
  182 + : Image.asset(
  183 + Utils.getImgPath('no_image'),
  184 + width: double.infinity,
  185 + height: w(280),
  186 + fit: BoxFit.cover,
  187 + ),
179 Positioned( 188 Positioned(
180 - bottom: -w(64), 189 + bottom: _height / 2,
181 child: Container( 190 child: Container(
  191 + key: globalKey,
  192 + width: ScreenUtil().screenWidth -
  193 + w(20) * 2,
182 // width: double.infinity, 194 // width: double.infinity,
183 // height: w(128), 195 // height: w(128),
184 padding: EdgeInsets.symmetric( 196 padding: EdgeInsets.symmetric(
@@ -193,6 +205,8 @@ class _CouponPosterPageState extends State<CouponPosterPage> { @@ -193,6 +205,8 @@ class _CouponPosterPageState extends State<CouponPosterPage> {
193 borderRadius: 205 borderRadius:
194 BorderRadius.circular(r(8))), 206 BorderRadius.circular(r(8))),
195 child: Column( 207 child: Column(
  208 + // mainAxisSize: ,
  209 + // main
196 crossAxisAlignment: 210 crossAxisAlignment:
197 CrossAxisAlignment.start, 211 CrossAxisAlignment.start,
198 children: [ 212 children: [
@@ -1718,14 +1718,14 @@ class Utils { @@ -1718,14 +1718,14 @@ class Utils {
1718 afterImg = await yourFile.readAsBytes(); 1718 afterImg = await yourFile.readAsBytes();
1719 } 1719 }
1720 1720
1721 - IMG.Image decodedImage = IMG.decodeImage(data);  
1722 - print(decodedImage.width);  
1723 - print(decodedImage.height);  
1724 -  
1725 - IMG.Image decodedImageafterImg = IMG.decodeImage(afterImg);  
1726 - print(decodedImageafterImg.width);  
1727 - print(decodedImageafterImg.height);  
1728 - debugPrint("newnenwnewnnwen图片的大小:${size(afterImg.length)}"); 1721 + // IMG.Image decodedImage = IMG.decodeImage(data);
  1722 + // print(decodedImage.width);
  1723 + // print(decodedImage.height);
  1724 +
  1725 + // IMG.Image decodedImageafterImg = IMG.decodeImage(afterImg);
  1726 + // print(decodedImageafterImg.width);
  1727 + // print(decodedImageafterImg.height);
  1728 + // debugPrint("newnenwnewnnwen图片的大小:${size(afterImg.length)}");
1729 return afterImg; 1729 return afterImg;
1730 } 1730 }
1731 1731
@@ -121,7 +121,7 @@ dependencies: @@ -121,7 +121,7 @@ dependencies:
121 # 获取设备信息 121 # 获取设备信息
122 device_info: ^2.0.3 122 device_info: ^2.0.3
123 # flutter_sms: ^2.1.1 123 # flutter_sms: ^2.1.1
124 - flutter_sms: ^2.3.2 124 + flutter_sms: ^2.3.3
125 125
126 126
127 # 获取通讯录 127 # 获取通讯录
@@ -219,6 +219,7 @@ dependencies: @@ -219,6 +219,7 @@ dependencies:
219 image_gallery_saver: ^2.0.3 219 image_gallery_saver: ^2.0.3
220 flutter_image_compress: ^1.1.3 220 flutter_image_compress: ^1.1.3
221 image: ^4.0.15 221 image: ^4.0.15
  222 + # image_cropper: ^3.0.1
222 image_cropper: ^4.0.1 223 image_cropper: ^4.0.1
223 pin_code_fields: ^7.4.0 224 pin_code_fields: ^7.4.0
224 # 二维码扫描 225 # 二维码扫描
@@ -239,6 +240,7 @@ dependencies: @@ -239,6 +240,7 @@ dependencies:
239 # 生成excel 240 # 生成excel
240 excel: ^3.0.0 241 excel: ^3.0.0
241 # workmanager: ^0.5.1 242 # workmanager: ^0.5.1
  243 +
242 244
243 245
244 246