setValue<K extends Object, V> static method

void setValue<K extends Object, V>(
  1. BuildContext context,
  2. K key,
  3. V value

Changes the app model's value for key and rebuilds any widgets that have created a dependency on key with SharedAppData.getValue.

If value is == to the current value of key then nothing is rebuilt.

The value is expected to be immutable because intrinsic changes to the value will not cause dependent widgets to be rebuilt.

Unlike SharedAppData.getValue, this method does not create a dependency between context and key.

The type parameter K is the type of the value's keyword and V is the type of the value.


static void setValue<K extends Object, V>(BuildContext context, K key, V value) {
  final _SharedAppModel? model = context.getInheritedWidgetOfExactType<_SharedAppModel>();
  assert(_debugHasSharedAppData(model, context, 'setValue'));
  model!.sharedAppDataState.setValue<K, V>(key, value);