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) {
  var value = namedArguments[const Symbol('value')];
  if (value == null) {
    throw "value required in Slider";
  }
  var onChanged = namedArguments[const Symbol('onChanged')];
  if (onChanged == null) {
    throw "onChanged required in Slider";
  }
  double min = parseDouble(namedArguments[const Symbol('min')]) ?? 0;
  double max = parseDouble(namedArguments[const Symbol('max')]) ?? 1;
  int? divisions;
  var divisionsParse = namedArguments[const Symbol('divisions')];
  if (divisionsParse != null) {
    divisions = divisionsParse as int;
  }
  String? label;
  var labelParse = namedArguments[const Symbol('label')];
  if (labelParse != null) {
    label = labelParse as String;
  }
  Color? activeColor;
  var activeColorParse = namedArguments[const Symbol('activeColor')];
  if (activeColorParse != null) {
    activeColor = activeColorParse as Color;
  }
  Color? inactiveColor;
  var inactiveColorParse = namedArguments[const Symbol('inactiveColor')];
  if (inactiveColorParse != null) {
    inactiveColor = inactiveColorParse as Color;
  }
  Color? thumbColor;
  var thumbColorParse = namedArguments[const Symbol('thumbColor')];
  if (thumbColorParse != null) {
    thumbColor = thumbColorParse as Color;
  }
  bool autofocus = false;
  var autofocusParse = namedArguments[const Symbol('autofocus')];
  if (autofocusParse != null) {
    autofocus = autofocusParse as bool;
  }
  return Slider(
    value: value as double,
    min: min,
    max: max,
    divisions: divisions,
    label: label,
    activeColor: activeColor,
    inactiveColor: inactiveColor,
    thumbColor: thumbColor,
    autofocus: autofocus,
    onChanged: (value) {
      (onChanged as LoxFunction).call(interpreter, [value], {});
    },
  );
}