MinButtonGroup<T> class

Grupo de botones con selección única, completamente controlado desde afuera.

Widget genérico <T> que trabaja con cualquier tipo de dato. Recibe una lista de MinButtonGroupOption, el valor seleccionado actualmente y un callback onChanged.

Características

  • Selección única controlada (controlled component).
  • Estados visuales: seleccionado, no seleccionado, deshabilitado, hover, pressed.
  • Animaciones suaves de selección.
  • Bordes redondeados con esquinas internas planas.
  • Soporte de accesibilidad (Semantics).
  • Responsive: se adapta al tamaño del contenido (horizontal y vertical).

Uso básico

enum Color { red, green, blue }

MinButtonGroup<Color>(
  options: const [
    MinButtonGroupOption(value: Color.red),
    MinButtonGroupOption(value: Color.green),
    MinButtonGroupOption(value: Color.blue),
  ],
  value: _selectedColor,
  onChanged: (color) => setState(() => _selectedColor = color),
  labelBuilder: (color) => Text(color.name),
)

Con opciones deshabilitadas

MinButtonGroup<String>(
  options: const [
    MinButtonGroupOption(value: 'a'),
    MinButtonGroupOption(value: 'b', enabled: false),
    MinButtonGroupOption(value: 'c'),
  ],
  value: _selected,
  onChanged: (v) => setState(() => _selected = v),
  labelBuilder: (v) => Text(v),
)
Inheritance

Constructors

MinButtonGroup({Key? key, required List<MinButtonGroupOption<T>> options, required T? value, required ValueChanged<T> onChanged, required Widget labelBuilder(T value), Axis direction = Axis.horizontal, MinButtonSize size = MinButtonSize.md, MinButtonVariant variant = MinButtonVariant.outline, String? semanticLabel})
const

Properties

direction Axis
Dirección del grupo: horizontal (default) o vertical.
final
hashCode int
The hash code for this object.
no setterinherited
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
labelBuilder Widget Function(T value)
Callback que renderiza el widget de texto para cada opción.
final
onChanged ValueChanged<T>
Callback llamado cuando se selecciona una opción.
final
options List<MinButtonGroupOption<T>>
Lista de opciones disponibles en el grupo.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
semanticLabel String?
Etiqueta de accesibilidad del grupo.
final
size MinButtonSize
Tamaño aplicado a todos los botones del grupo.
final
value → T?
Valor seleccionado actualmente.
final
variant MinButtonVariant
Variante visual aplicada a todos los botones no seleccionados.
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<MinButtonGroup<T>>
Creates the mutable state for this widget at a given location in the tree.
override
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited