$new static method

$Value? $new(
  1. Runtime runtime,
  2. $Value? thisValue,
  3. List<$Value?> args
)

Wrapper for the Autocomplete.new constructor

Implementation

static $Value? $new(Runtime runtime, $Value? thisValue, List<$Value?> args) {
  if (args[3] == null) {
    return $Autocomplete.wrap(
      Autocomplete(
        key: args[0]?.$value,
        optionsBuilder: (TextEditingValue textEditingValue) async {
          final future = (args[1]! as EvalCallable)(runtime, null, [
            $TextEditingValue.wrap(textEditingValue),
          ]);
          final value = await future!.$value;
          return (value?.$value as Iterable<dynamic>).cast();
        },
        displayStringForOption: args[2] == null
            ? RawAutocomplete.defaultStringForOption
            : (dynamic option) {
                return (args[2]! as EvalCallable?)?.call(runtime, null, [
                  option is $Value ? option : $Object(option),
                ])?.$value;
              },
        focusNode: args[4]?.$value,
        onSelected: args[5] == null
            ? null
            : (dynamic option) {
                (args[5]! as EvalCallable?)
                    ?.call(runtime, null, [option is $Value ? option : $Object(option)]);
              },
        optionsMaxHeight: args[6]?.$value ?? 200.0,
        optionsViewBuilder: args[7] == null
            ? null
            : (
                BuildContext context,
                void Function(Object option) onSelected,
                Iterable<Object> options,
              ) {
                return (args[7]! as EvalCallable?)?.call(runtime, null, [
                  runtime.wrapAlways(context),
                  $Function((runtime, target, args) {
                    onSelected(args[0]!.$value);
                    return const $null();
                  }),
                  $Iterable.wrap(options),
                ])?.$value;
              },
        optionsViewOpenDirection:
            args[8]?.$value ?? OptionsViewOpenDirection.down,
        textEditingController: args[9]?.$value,
        initialValue: args[10]?.$value,
      ),
    );
  } else {
    return $Autocomplete.wrap(
      Autocomplete(
        key: args[0]?.$value,
        optionsBuilder: (TextEditingValue textEditingValue) {
          return (args[1]! as EvalCallable)(runtime, null, [
            $TextEditingValue.wrap(textEditingValue),
          ])?.$value;
        },
        displayStringForOption: args[2] == null
            ? RawAutocomplete.defaultStringForOption
            : (dynamic option) {
                return (args[2]! as EvalCallable?)?.call(runtime, null, [
                  $Object(option),
                ])?.$value;
              },
        fieldViewBuilder: (
          BuildContext context,
          TextEditingController textEditingController,
          FocusNode focusNode,
          void Function() onFieldSubmitted,
        ) {
          return (args[3]! as EvalCallable?)?.call(runtime, null, [
            runtime.wrapAlways(context),
            runtime.wrapAlways(textEditingController),
            runtime.wrapAlways(focusNode),
            $Function((runtime, target, args) {
              onFieldSubmitted();
              return const $null();
            }),
          ])?.$value;
        },
        focusNode: args[4]?.$value,
        onSelected: args[5] == null
            ? null
            : (dynamic option) {
                (args[5]! as EvalCallable?)
                    ?.call(runtime, null, [$Object(option)]);
              },
        optionsMaxHeight: args[6]?.$value ?? 200.0,
        optionsViewBuilder: args[7] == null
            ? null
            : (
                BuildContext context,
                void Function(Object option) onSelected,
                Iterable<Object> options,
              ) {
                return (args[7]! as EvalCallable?)?.call(runtime, null, [
                  runtime.wrapAlways(context),
                  $Function((runtime, target, args) {
                    onSelected(args[0]!.$value);
                    return const $null();
                  }),
                  $Iterable.wrap(options),
                ])?.$value;
              },
        optionsViewOpenDirection:
            args[8]?.$value ?? OptionsViewOpenDirection.down,
        textEditingController: args[9]?.$value,
        initialValue: args[10]?.$value,
      ),
    );
  }
}