onDataSourceSuccess method
Implementation
@override
Future<bool> onDataSourceSuccess(IDataSource? source, Data? list) async
{
try
{
if (prototype == null) return true;
// clear options
this.options.forEach((option) => option.dispose());
this.options.clear();
int i = 0;
if (addempty == true)
{
options.add(OptionModel(this, "${this.id}-$i", value: ''));
i = i + 1;
}
// build options
if ((list != null) && (source != null))
{
// build options
list.forEach((row)
{
XmlElement? prototype = S.fromPrototype(this.prototype, "${this.id}-$i");
i = i + 1;
var model = OptionModel.fromXml(this, prototype, data: row);
if (model != null) options.add(model);
});
}
// sets the data
setData();
// notify listeners
notifyListeners('options', options);
}
catch(e)
{
Log().error('Error building list. Error is $e');
}
return true;
}