by method
Add a pre-condition to choosing the correct Inheritable of T
when
are multiple Inheritable of T
in the enclosing context.
For example, If there exists an overriding-hierarchy for String
such that
Inheritable<String>(
key: Key('my-key'),
value: 'A',
child: Inheritable<String>(
value: 'B',
child: MyWidget(),
)
)
Ordinarily, value 'B'
overrides value 'A'
, but it can be accessed and
depended upon using following construct.
final result = aspect.by((w) => w.key == 'my-key');
Here by runs on the Inheritable itself whereas other similar constructs run
on Inheritable.value
.
Implementation
TransformingAspect<A, T> by(InheritableAspectSatisfied<T> fn) {
return _ByInheritableAspect<A, T>(this, fn);
}