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) {
  Widget? child;
  var childParsed = namedArguments[const Symbol('child')];
  if (childParsed != null) {
    child = childParsed as Widget;
  }
  Widget? icon;
  var iconParsed = namedArguments[const Symbol('icon')];
  if (iconParsed != null) {
    icon = iconParsed as Widget;
  }
  var itemBuilder = namedArguments[const Symbol('itemBuilder')];
  if (itemBuilder == null) {
    throw "itemBuilder required in ListView.builder";
  }
  Function(Object)? onSelected;
  var onSelectedParsed = namedArguments[const Symbol('onSelected')];
  if (onSelectedParsed != null) {
    onSelected = (Object b) {
      (onSelectedParsed as LoxFunction).call(interpreter, [b], {});
    };
  }
  Color? color;
  var colorParsed = namedArguments[const Symbol('color')];
  if (colorParsed != null) {
    color = colorParsed as Color;
  }
  Offset offset = const Offset(0, 0);
  var offsetParsed = namedArguments[const Symbol('offset')];
  if (offsetParsed != null) {
    offset = offsetParsed as Offset;
  }
  double? elevation = parseDouble(namedArguments[const Symbol('elevation')]);
  double? iconSize = parseDouble(namedArguments[const Symbol('iconSize')]);
  bool enabled = true;
  var enabledParsed = namedArguments[const Symbol('enabled')];
  if (enabledParsed != null) {
    enabled = enabledParsed as bool;
  }
  EdgeInsetsGeometry padding = const EdgeInsets.all(8.0);
  var paddingParsed = namedArguments[const Symbol('padding')];
  if (paddingParsed != null) {
    padding = paddingParsed as EdgeInsetsGeometry;
  }
  Object? initialValue;
  var initialValueParsed = namedArguments[const Symbol('initialValue')];
  if (initialValueParsed != null) {
    initialValue = initialValueParsed;
  }
  String? tooltip;
  var tooltipParsed = namedArguments[const Symbol('tooltip')];
  if (tooltipParsed != null) {
    tooltip = tooltipParsed as String;
  }
  ShapeBorder? shape;
  var shapeParsed = namedArguments[const Symbol('shape')];
  if (shapeParsed != null) {
    shape = shapeParsed as ShapeBorder;
  }
  return PopupMenuButton(
      child: child,
      icon: icon,
      offset: offset,
      enabled: enabled,
      initialValue: initialValue,
      padding: padding,
      shape: shape,
      tooltip: tooltip,
      itemBuilder: (BuildContext context) {
        return ((itemBuilder as LoxCallable).call(interpreter, [context], {})
                as List)
            .cast<PopupMenuEntry<Object>>();
      },
      onSelected: onSelected,
      color: color,
      iconSize: iconSize,
      elevation: elevation);
}