setState method
Turns state of node id on or off: the nodes its state styles
patch re-apply (see api.StateStyles).
Implementation
void setState(String id, api.WidgetState state, bool on, {Object? instance}) {
final key = (id, instance);
final current = _states[key] ?? const <api.WidgetState>{};
if (current.contains(state) == on) return;
final next = {...current};
on ? next.add(state) : next.remove(state);
next.isEmpty ? _states.remove(key) : _states[key] = next;
final affected = {id, ...?sourceOf(instance).node(id)?.behaviors.states.targets};
for (final b in _boxes.values.toList()) {
if (b.instance == instance && affected.contains(b.id)) b._apply();
}
}