ScrollPickerFormField<T> constructor

ScrollPickerFormField<T>({
  1. required List<T> values,
  2. required ScrollPickerDecoration decoration,
  3. required FormFieldSetter<T> onSaved,
  4. required String childToString(
    1. T
    ),
  5. int? initialIndex,
  6. void onChanged(
    1. T value
    )?,
  7. Key? key,
})

Implementation

ScrollPickerFormField({
  required List<T> values,
  required ScrollPickerDecoration decoration,
  required FormFieldSetter<T> super.onSaved,
  required String Function(T) childToString,
  int? initialIndex,
  void Function(T value)? onChanged,
  super.key,
}) : super(
        initialValue: values[initialIndex ?? (values.length / 2).floor()],
        builder: (FormFieldState<T> state) => ScrollPicker(
          list: values.map((e) => childToString(e)).toList(),
          decoration: decoration,
          initialIndex: initialIndex,
          onChanged: (int index) {
            onChanged?.call(values[index]);

            state.didChange(values[index]);
          },
        ),
      );