CycleButton<T> constructor

CycleButton<T>({
  1. Key? key,
  2. required List<T> values,
  3. required Widget builder(
    1. BuildContext,
    2. T
    ),
  4. required T initialValue,
  5. dynamic onChanged(
    1. T value
    )?,
  6. ButtonStyle style = const ButtonStyle.ghost(),
  7. ButtonSize size = ButtonSize.normal,
  8. ButtonDensity density = ButtonDensity.icon,
  9. ButtonShape shape = ButtonShape.rectangle,
  10. FocusNode? focusNode,
  11. bool disableTransition = false,
  12. ValueChanged<bool>? onHover,
  13. ValueChanged<bool>? onFocus,
  14. bool? enableFeedback,
})

Creates a CycleButton with the given values and callbacks.

The values map must have at least one entry. The initialValue must be a key in the values map.

Implementation

CycleButton({
  super.key,
  required this.values,
  required this.builder,
  required this.initialValue,
  this.onChanged,
  this.style = const ButtonStyle.ghost(),
  this.size = ButtonSize.normal,
  this.density = ButtonDensity.icon,
  this.shape = ButtonShape.rectangle,
  this.focusNode,
  this.disableTransition = false,
  this.onHover,
  this.onFocus,
  this.enableFeedback,
})  : assert(values.isNotEmpty, 'Values map must not be empty'),
      assert(values.contains(initialValue),
          'Initial value must be a key in the values map');