replaceWidget function
Implementation
Future<void> replaceWidget(WidgetModel model, List<dynamic> arguments) async {
// fml
var xml = elementAt(arguments, 0);
// get my position in my parents child list
int? index = (model.parent?.children?.contains(model) ?? false)
? model.parent?.children?.indexOf(model)
: null;
// silent
bool silent = toBool(elementAt(arguments, 1)) ?? true;
if (xml == null || xml is! String) return;
// index should never be null
if (index != null) {
// dispose of myself
model.dispose();
// remove myself from the list
model.parent?.children?.removeAt(index);
// add new fml
await _appendXml(model, xml, index, silent);
}
}