WidgetEventController.by constructor

WidgetEventController.by({
  1. bool focused = false,
  2. bool hovered = false,
  3. bool pressed = false,
  4. bool dragged = false,
  5. bool selected = false,
  6. bool indeterminate = false,
  7. bool disabled = false,
  8. bool error = false,
  9. bool loading = false,
  10. ValueSetter<Set<WidgetEvent>>? onChanged,
})

Creates a new instance of WidgetEventController.

Optionally allows setting the initial state of the events.

  • focused: Whether the widget is currently focused.
  • hovered: Whether the widget is currently hovered.
  • pressed: Whether the widget is currently pressed.
  • dragged: Whether the widget is currently dragged.
  • selected: Whether the widget is currently selected.
  • disabled: Whether the widget is currently disabled.
  • indeterminate: Whether the widget is currently indeterminate.
  • error: Whether the widget is currently in an error state.
  • loading: Whether the widget is currently loading.
  • onChanged: A callback that will be invoked whenever the set of active events changes.

Implementation

WidgetEventController.by({
  bool focused = false,
  bool hovered = false,
  bool pressed = false,
  bool dragged = false,
  bool selected = false,
  bool indeterminate = false,
  bool disabled = false,
  bool error = false,
  bool loading = false,
  this.onChanged,
}) : value = ({
        WidgetEvent.focused: focused,
        WidgetEvent.hovered: hovered,
        WidgetEvent.pressed: pressed,
        WidgetEvent.dragged: dragged,
        WidgetEvent.selected: selected,
        WidgetEvent.indeterminate: indeterminate,
        WidgetEvent.disabled: disabled,
        WidgetEvent.error: error,
        WidgetEvent.loading: loading,
      }..removeWhere((key, value) => !value))
          .keys
          .toSet();