hasEffectiveTextStyleWhere method
A WidgetMatcher for Text widgets that performs specific assertions by applying a custom matcher function to TextStyle properties.
Example:
spot<Text>().withText('foo').existsOnce()
.hasEffectiveTextStyleWhere(
(style) => style
..fontSize.isGreaterOrEqual(14)
..letterSpacing.isNotNull()
..fontStyle.equals(FontStyle.italic),
);
See also:
- hasEffectiveTextStyle, for matching Text widgets by performing a singular assertion against a fixed TextStyle value.
Implementation
WidgetMatcher<Text> hasEffectiveTextStyleWhere(MatchProp<TextStyle> match) {
return hasProp(
elementSelector: (subject) => subject.context.nest<TextStyle?>(
() => ['has "textStyle"'],
(Element element) => Extracted.value(_extractTextStyle(element)),
),
match: match.hideNullability(),
);
}