我有这样的场景,我必须从这样的图像中获取 UInt8List :
List stuff = image.toByteData().buffer.asUInt8List()
Run Code Online (Sandbox Code Playgroud)
做一些操作并回到Image。
我尝试了以下方法:
List stuff = image.toByteData().buffer.asUInt8List()
ui.decodeImageFromList(stuff, (image){
// do stuff with image
});
Run Code Online (Sandbox Code Playgroud)
但我不断收到此异常:
E/flutter (10201): [ERROR:flutter/lib/ui/painting/codec.cc(97)] Failed decoding image. Data is either invalid, or it is encoded using an unsupported format.
E/flutter (10201): [ERROR:flutter/shell/common/shell.cc(186)] Dart Error: Unhandled exception:
...
Run Code Online (Sandbox Code Playgroud)
请注意,即使列表中没有任何更改,也会引发异常。如何使列表具有可编码格式?
是否有任何颤动的小部件可阻止儿童以任何方式在容器外部绘画?
我有一个带孩子的容器,孩子可能会进行一些转换(例如缩放和旋转),因此可以在外部绘制
我想将孩子的绘画限制在父容器内,就像使用CSS的div一样overflow:hidden;。
一个样品:
return Container( // the one with overflow hidden -ish behavior
height: 300.0,
child: TheTransformingChild() // the one that can get bigger that container
)
Run Code Online (Sandbox Code Playgroud) 跑完后flutter upgrade我面临一些颤抖的问题
我有这个类存储minScale和maxScale.
在构造函数中,我想断言它们之间的间隔.由于这些值可以是枚举的双精度或实例,因此我必须在比较之前计算它们.
构造函数和断言的代码:
class ScaleBoundaries {
final dynamic _minScale;
final dynamic _maxScale;
Size size;
ImageInfo imageInfo;
ScaleBoundaries(this._minScale, this._maxScale, { @required this.size, @required this.imageInfo}) :
assert(_minScale is double || _minScale is PhotoViewScaleBoundary),
assert(_maxScale is double || _maxScale is PhotoViewScaleBoundary),
assert(computeMinScale() <= computeMaxScale());
Run Code Online (Sandbox Code Playgroud)
这给了我以下错误:
compiler message: file:///.../photo_view/lib/photo_view_scale_boundaries.dart:14:37: Error: Can't access 'this' in a field initializer to read 'computeMaxScale'.
compiler message: assert(computeMinScale() <= computeMaxScale());
compiler message: ^^^^^^^^^^^^^^^
compiler message: file:///.../photo_view/lib/photo_view_scale_boundaries.dart:14:16: Error: Can't access 'this' in …Run Code Online (Sandbox Code Playgroud)