NineImage class

九图处理工具

通过传入.9.png的图,然后通过计算ImagePixels方法获取到所有图片的像素信息, 通过遍历四周像素坐标系获得拉伸区域和填充区域,即得到自带伸缩的图形展示区域根据child大小拉伸。

hideLines defulte = true 表示默认裁切.9的黑边像素.

imageProvider 原始.9图片对象, AssetImage("assets/xxx.9.png") 这里最好是一倍图 并且.9图最好设置最小两个像素点,否则会出现识别失败情况

child 内容填充区域用于展.9图内容,比如文本,图片等。

参考坐标系

注意,这里使用centerSlice之后,显示图片的大小大于原图的情况下才可以使用这个属性,要不然会报错.理由是下面这个源码: assert(sourceSize == inputSize, 'centerSlice was used with a BoxFit that does not guarantee that the image is fully visible.');

Inheritance

Constructors

NineImage({Key? key, required ImageProvider<Object> imageProvider, required Widget child, bool hideLines = true})
const

Properties

child Widget
child widget for example Text("Hi welcome ")
final
hashCode int
The hash code for this object.
no setterinherited
hideLines bool
hide lines in 9 patch image
final
imageProvider ImageProvider<Object>
image provider for example use AssetImage("assets/orange.9.png")
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

build(BuildContext context) Widget
Describes the part of the user interface represented by this widget.
override
createElement() StatelessElement
Creates a StatelessElement to manage this widget's location in the tree.
inherited
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
getDefulteSize(dynamic paddBottomLeft, dynamic paddBottomRight, dynamic paddRightTop, dynamic paddRightBottom, dynamic width, dynamic heiget) EdgeInsets
判断图片内容填充区域最小范围
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited