export method
export the runtime widget to json
Implementation
@override
Map<String, dynamic>? export(Widget? widget, BuildContext? buildContext) {
if (_isMatchAssetImageType(widget)) {
var realWidget = widget as Image;
late AssetImage assetImage;
if (realWidget.image is AssetImage) {
assetImage = realWidget.image as AssetImage;
} else if (realWidget.image is ResizeImage) {
var t = realWidget.image as ResizeImage;
assetImage = t.imageProvider as AssetImage;
}
return <String, dynamic>{
"type": widgetName,
"name": assetImage.assetName,
"semanticLabel": realWidget.semanticLabel,
"excludeFromSemantics": realWidget.excludeFromSemantics,
"width": realWidget.width,
"height": realWidget.height,
"color": realWidget.color != null
? realWidget.color!.value.toRadixString(16)
: null,
"colorBlendMode": realWidget.colorBlendMode != null
? exportBlendMode(realWidget.colorBlendMode)
: null,
"fit": realWidget.fit != null ? exportBoxFit(realWidget.fit) : null,
"alignment": realWidget.alignment != null
? exportAlignment(realWidget.alignment as Alignment?)
: null,
"repeat": realWidget.repeat != null
? exportImageRepeat(realWidget.repeat)
: null,
"centerSlice": realWidget.centerSlice != null
? exportRect(realWidget.centerSlice!)
: null,
"matchTextDirection": realWidget.matchTextDirection,
"gaplessPlayback": realWidget.gaplessPlayback,
"filterQuality": realWidget.filterQuality != null
? exportFilterQuality(realWidget.filterQuality)
: null
};
}
if (_isMatchExactAssetImageType(widget)) {
var realWidget = widget as Image;
late ExactAssetImage exactAssetImage;
if (realWidget.image is ExactAssetImage) {
exactAssetImage = realWidget.image as ExactAssetImage;
} else if (realWidget.image is ResizeImage) {
var t = realWidget.image as ResizeImage;
exactAssetImage = t.imageProvider as ExactAssetImage;
}
return <String, dynamic>{
"type": widgetName,
"name": exactAssetImage.assetName,
"semanticLabel": realWidget.semanticLabel,
"excludeFromSemantics": realWidget.excludeFromSemantics,
"scale": exactAssetImage.scale,
"width": realWidget.width,
"height": realWidget.height,
"color": realWidget.color != null
? realWidget.color!.value.toRadixString(16)
: null,
"colorBlendMode": realWidget.colorBlendMode != null
? exportBlendMode(realWidget.colorBlendMode)
: null,
"fit": realWidget.fit != null ? exportBoxFit(realWidget.fit) : null,
"alignment": realWidget.alignment != null
? exportAlignment(realWidget.alignment as Alignment?)
: null,
"repeat": realWidget.repeat != null
? exportImageRepeat(realWidget.repeat)
: null,
"centerSlice": realWidget.centerSlice != null
? exportRect(realWidget.centerSlice!)
: null,
"matchTextDirection": realWidget.matchTextDirection,
"gaplessPlayback": realWidget.gaplessPlayback,
"filterQuality": realWidget.filterQuality != null
? exportFilterQuality(realWidget.filterQuality)
: null
};
}
return null;
}