parse method
Widget
parse(
- Map<
String, dynamic> map, - BuildContext buildContext,
- ClickListener? listener
override
parse the json map into a flutter widget.
Implementation
@override
Widget parse(Map<String, dynamic> map, BuildContext buildContext,
ClickListener? listener) {
Alignment? alignment = parseAlignment(map['alignment']);
Color? color = parseHexColor(map['color']);
BoxConstraints constraints = parseBoxConstraints(map['constraints']);
//TODO: decoration, foregroundDecoration and transform properties to be implemented.
EdgeInsetsGeometry? margin = parseEdgeInsetsGeometry(map['margin']);
EdgeInsetsGeometry? padding = parseEdgeInsetsGeometry(map['padding']);
Map<String, dynamic>? childMap = map['child'];
Widget? child = childMap == null
? null
: DynamicWidgetBuilder.buildFromMap(childMap, buildContext, listener);
String? clickEvent =
map.containsKey("click_event") ? map['click_event'] : null;
var containerWidget = Container(
alignment: alignment,
padding: padding,
color: color,
margin: margin,
width: map['width']?.toDouble(),
height: map['height']?.toDouble(),
constraints: constraints,
child: child,
);
if (listener != null && clickEvent != null) {
return GestureDetector(
onTap: () {
listener.onClicked(clickEvent);
},
child: containerWidget,
);
} else {
return containerWidget;
}
}