resolve method
Resolves an InheritedProperties by calling callbacks on top of parent's values.
If the parent's values are unchanged, the cached resolved set will be used.
Implementation
InheritedProperties resolve(BuildContext context) {
final parentResolved = parent?.resolve(context) ??
const InheritedProperties._(null, [], TextStyle());
final scopedCallbacks = _callbacks;
if (scopedCallbacks == null) {
return parentResolved;
}
final cache = _cachedResolved;
if (cache != null && identical(parentResolved, _cachedParent)) {
return cache;
}
var resolving = parentResolved.copyWith(parent: parentResolved);
for (final callback in scopedCallbacks) {
resolving = callback(context, resolving);
assert(
identical(resolving.parent, parentResolved),
'The inherited properties set should be modified by calling copyWith() '
'to preserve parent reference.',
);
}
// performance critical
// keep track of both the parent's and the resolved set -> skip resolving if possible
// under normal circumstances, the root properties shouldn't be invalidated a lot
_cachedParent = parentResolved;
_cachedResolved = resolving;
return resolving;
}