update<R extends T> method
void
update<
R extends T>( - dynamic mutator(
- R s
), {
- bool shouldNotify = true,
- String? tag,
})
Implementation
void update<R extends T>(
dynamic Function(R s) mutator, {
bool shouldNotify = true,
String? tag,
}) {
assert(R == T,
'Type mismatch: update<$R> called on Injected<$T>. The type parameter must match exactly (no subtype).');
final R stateAsR = state as R;
final result = mutator(stateAsR);
if (result is T) {
try {
state = result;
} catch (_) {}
}
if (shouldNotify && WidgetsBinding.instance.isRootWidgetAttached) {
_TagRegistry.set(this, tag);
notify();
WidgetsBinding.instance
.addPostFrameCallback((_) => _TagRegistry.clear(this));
}
}