call method

  1. @override
Object? call(
  1. Interpreter interpreter,
  2. List<Object?> arguments,
  3. Map<Symbol, Object?> namedArguments
)
override

Implementation

@override
Object? call(Interpreter interpreter, List<Object?> arguments,
    Map<Symbol, Object?> namedArguments) {
  String? label;
  var labelParse = namedArguments[const Symbol('label')];
  if (labelParse != null) {
    label = labelParse as String;
  }
  Function()? onPressed;
  var onPressedParsed = namedArguments[const Symbol('onPressed')];
  if (onPressedParsed != null) {
    onPressed = () {
      (onPressedParsed as LoxFunction).call(interpreter, [], {});
    };
  }
  ContextMenuButtonType type = ContextMenuButtonType.custom;
  var typeParse = namedArguments[const Symbol('type')];
  if (typeParse != null) {
    type = typeParse as ContextMenuButtonType;
  }
  return ContextMenuButtonItem(
    label: label,
    type: type,
    onPressed: onPressed,
  );
}