onDataSourceSuccess method

  1. @override
Future<bool> onDataSourceSuccess(
  1. IDataSource source,
  2. dynamic list
)
override

Implementation

@override
Future<bool> onDataSourceSuccess(IDataSource source, dynamic list) async
{
  try
  {
    if (prototype == null) return true;

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

    // build options
    int i = 0;
    if ((list != null))
    list.forEach((row)
    {
      XmlElement? prototype = S.fromPrototype(this.prototype, "${this.id}-$i");
      i = i + 1;

      OptionModel? model = OptionModel.fromXml(parent, prototype, data: row);
      if (model != null) options.add(model);
    });

    // set data
    await setData();

    // notify
    notifyListeners('options', options);
  }
  catch(e)
  {
    Log().error('Error building list. Error is $e', caller: 'CHECKBOX');
  }
  return true;
}