registerWidget method

  1. @override
void registerWidget(
  1. String? groupId,
  2. Object widget
)
override

Implementation

@override
void registerWidget(String? groupId, Object widget) {
  if (groupId == null) return;

  final widgets = _groupWidgets.putIfAbsent(groupId, () => {});
  final wasEmpty = widgets.isEmpty;
  widgets.add(widget);

  logv('TappableActionGroupManager: Registered widget for group "$groupId" (${widgets.length} total)');

  // Cancel any pending auto-reset if widgets are being added
  if (wasEmpty && _groupResetTimers[groupId] != null) {
    logv('TappableActionGroupManager: Cancelling auto-reset for group "$groupId" - widget registered');
    _cancelAutoReset(groupId);

    // Only auto-enable if the group is still disabled and we're adding the first widget
    if (isGroupDisabled(groupId) && config.enableAutoReset) {
      logd('TappableActionGroupManager: Auto-enabling group "$groupId" - first widget registered');
      setGroupDisabled(groupId, false);
    }
  }
}