dikeboy / flutter-image-cut

Image clip by the dart. not native android or ios
31 stars 5 forks source link

运行报错 #1

Closed BinaryCraftsman closed 4 years ago

BinaryCraftsman commented 5 years ago

The following NoSuchMethodError was thrown building ImageDetailPage(dirty, dependencies: I/flutter ( 3238): [MediaQuery], state: _ImageDetailPageState#20106): I/flutter ( 3238): Class 'Future' has no instance getter 'width'. I/flutter ( 3238): Receiver: Instance of 'Future'

报错原因是因为编译器搞不清楚image类是painting.dart里的 还是image.dart里的

BinaryCraftsman commented 5 years ago

将image_cut.dart的第183行image的类型由var 改为flutterui.Image即可,但同时方法开头要加上async,“=”后面要加上await代码如下 onPressed: ()async{ //convert the clip square to the clip image double rate =this.image.width.toDouble()/width; var source = Rect.fromLTWH(_points[2].dx rate,(_points[2].dy-(height-_points[3].dy)/2) rate,cWidth rate,cHeight rate); var dest = Rect.fromLTWH(0,0,cWidth rate,cHeight rate); PictureRecorder recorder = PictureRecorder(); Canvas canvas2 = Canvas(recorder); Paint paint2 = new Paint(); canvas2.drawImageRect(image, source, dest, paint2); flutterui.Image image2 = await recorder.endRecording().toImage(dest.width.toInt(), dest.height.toInt()); Navigator.push(context,new MaterialPageRoute(builder: (context) => ImageDetailPage(title: "image",image: image2)));

            }),

同时把ImageDetailPage类及后续会调用image的类的image属性都改为相同即可

AXXZSTHL commented 4 years ago

Compiler message: lib/image_cut.dart:29:37: Error: Too few positional arguments: 2 required, 0 given. stream.removeListener(listener()); ^ lib/image_cut.dart:29:37: Error: This expression has type 'void' and can't be used. stream.removeListener(listener()); ^ lib/image_cut.dart:32:24: Error: The argument type 'void Function(ImageInfo, bool)' can't be assigned to the parameter type 'ImageStreamListener'.

FAILURE: Build failed with an exception.

BUILD FAILED in 15s

AXXZSTHL commented 4 years ago

更新flutter版本1.7.8+hotfix.3后出现以下错误

Error: The argument type 'Null Function(ImageInfo, bool)' can't be assigned to the parameter type 'ImageStreamListener'.

解决方法:

将出现错误的地方

_imageStream.addListener(_handleImageLoaded);

改成

_imageStream.addListener(ImageStreamListener(_handleImageLoaded));

dikeboy commented 4 years ago

已修复