add static method
void
add(})
Adds more substitutions to the existing ancestor GetScope.
These substitutes are automatically removed when the associated BuildContext is unmounted.
Implementation
static void add(
BuildContext context, {
Map<GetAny, GetAny> getObjects = const {},
Map<GetAny, ValueRef> listenables = const {},
bool throwIfMissing = true,
}) {
final _OverrideContainer? container = context.dependOnInheritedWidgetOfExactType(
aspect: {
for (final MapEntry(:key, :value) in getObjects.entries) key: value.hooked,
...listenables,
},
);
assert(() {
if (container != null || !throwIfMissing) return true;
throw FlutterError.fromParts([
ErrorSummary('Ancestor GetScope not found.'),
ErrorDescription(
'GetScope.add() was called using a BuildContext '
'that was unable to locate an ancestor GetScope.',
),
ErrorDescription('The widget that attempted this call was:'),
context.widget.toDiagnosticsNode(),
]);
}());
}