deserialize method

  1. @override
void deserialize(
  1. XmlElement xml
)
override

Deserializes the FML template elements, attributes and children

Implementation

@override
void deserialize(XmlElement xml)
{
  // deserialize
  super.deserialize(xml);

  // set properties
  value = Xml.get(node: xml, tag: 'value');
  hint = Xml.get(node: xml, tag: 'hint');
  border = Xml.get(node: xml, tag: 'border');
  bordercolor = Xml.get(node: xml, tag: 'bordercolor');
  borderwidth = Xml.get(node: xml, tag: 'borderwidth');
  radius = Xml.get(node: xml, tag: 'radius');
  inputenabled = Xml.get(node: xml, tag: 'inputenabled');
  typeahead = Xml.get(node: xml, tag: 'typeahead');
  matchtype = Xml.get(node: xml, tag: 'matchtype') ?? Xml.get(node: xml, tag: 'searchtype');

  String? empty = Xml.get(node: xml, tag: 'addempty');
  if (S.isBool(empty)) addempty = S.toBool(empty);

  // clear options
  this.options.forEach((option) => option.dispose());
  this.options.clear();

  // Build options
  List<OptionModel> options = findChildrenOfExactType(OptionModel).cast<OptionModel>();

  // set prototype
  if ((!S.isNullOrEmpty(datasource)) && (options.isNotEmpty))
  {
    prototype = S.toPrototype(options[0].element.toString());
    options.removeAt(0);
  }

  // build options
  options.forEach((option) => this.options.add(option));

  // Set selected option
  setData();
}