execute method

  1. @override
Future<bool?> execute(
  1. String caller,
  2. String propertyOrFunction,
  3. List arguments
)
override

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)
  {
  // selects the item by index
    case "select" :
      int index = S.toInt(S.item(arguments, 0)) ?? -1;
      if (index >= 0 && index < items.length)
      {
        var model = items[index];
        if (model != null && model.selected == false) onTap(model);
      }
      return true;

  // de-selects the item by index
    case "deselect" :
      int index = S.toInt(S.item(arguments, 0)) ?? -1;
      if (index >= 0 && _dataset != null && index < _dataset!.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);
}