deserialize method
Deserializes the FML template elements, attributes and children
Implementation
@override
void deserialize(XmlElement xml) {
// deserialize
super.deserialize(xml);
// set constraints
_modelConstraints.minWidth =
S.toDouble(Xml.get(node: xml, tag: 'minwidth'));
_modelConstraints.maxWidth =
S.toDouble(Xml.get(node: xml, tag: 'maxwidth'));
_modelConstraints.minHeight =
S.toDouble(Xml.get(node: xml, tag: 'minheight'));
_modelConstraints.maxHeight =
S.toDouble(Xml.get(node: xml, tag: 'maxheight'));
// properties
visible = Xml.get(node: xml, tag: 'visible');
enabled = Xml.get(node: xml, tag: 'enabled');
width = Xml.get(node: xml, tag: 'width');
height = Xml.get(node: xml, tag: 'height');
halign = Xml.get(node: xml, tag: 'halign');
valign = Xml.get(node: xml, tag: 'valign');
onscreen = Xml.get(node: xml, tag: 'onscreen');
offscreen = Xml.get(node: xml, tag: 'offscreen');
// view requires a VisibilityDetector if either onstage or offstage is set or
// someone is bound to my visibility
_needsVisibilityDetector = !S.isNullOrEmpty(onscreen) || !S.isNullOrEmpty(offscreen) ||
WidgetModel.isBound(this, Binding.toKey(id, 'visiblearea')) ||
WidgetModel.isBound(this, Binding.toKey(id, 'visibleheight')) ||
WidgetModel.isBound(this, Binding.toKey(id, 'visiblewidth'));
// pad is always defined as an attribute. PAD as an element name is the PADDING widget
_paddings = Xml.attribute(node: xml, tag: 'pad');
// tip
List<TooltipModel> tips = findChildrenOfExactType(TooltipModel).cast<TooltipModel>();
if (tips.isNotEmpty)
{
tipModel = tips.first;
removeChildrenOfExactType(TooltipModel);
}
// add animations
children?.forEach((child)
{
if (child is AnimationModel)
{
if (animations == null) animations = [];
animations!.add(child);
}
});
// remove animations from child list
if (animations != null) children?.removeWhere((element) => animations!.contains(element));
}