Closed BinaryCraftsman closed 4 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属性都改为相同即可
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.
Where: Script 'D:\Soft\Flutter\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 652
What went wrong: Execution failed for task ':app:compileflutterBuildDebugandroid-arm'.
Process 'command 'D:\Soft\Flutter\flutter\bin\flutter.bat'' finished with non-zero exit value 1
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 15s
更新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));
已修复
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里的