execute method
Implementation
@override
Future<bool?> execute(
String caller, String propertyOrFunction, List<dynamic> arguments) async {
/// setter
if (scope == null) return null;
var function = propertyOrFunction.toLowerCase().trim();
switch (function) {
// export the data
case "export":
await export();
return true;
// selects the item by index
case "select":
int index = toInt(elementAt(arguments, 0)) ?? -1;
if (index >= 0 && index < items.length) {
var model = items[index];
if (model != null && !model.selected) onTap(model);
}
return true;
// sort the grid
case "sort":
var field = elementAt(arguments, 0);
var type = elementAt(arguments, 1) ?? 'string';
var ascending = toBool(elementAt(arguments, 2)) ?? true;
_sort(field, type, ascending);
return true;
// scroll +/- pixels
case "scroll":
scroll(toDouble(elementAt(arguments, 0)), animate: toBool(elementAt(arguments, 1)) ?? true);
return true;
// scroll to item by id
case "scrollto":
scrollTo(toStr(elementAt(arguments, 0)), toStr(elementAt(arguments, 1)), animate: toBool(elementAt(arguments, 2)) ?? true);
return true;
// de-selects the item by index
case "deselect":
int index = toInt(elementAt(arguments, 0)) ?? -1;
if (index >= 0 && data != null && index < data.length) {
var model = items[index];
if (model != null && model.selected == true) onTap(model);
}
return true;
// de-selects the item by index
case "clear":
onTap(null);
return true;
}
return super.execute(caller, propertyOrFunction, arguments);
}