hasEffectiveTextStyle method
A WidgetMatcher for Text widgets that performs a singular assertion against a fixed TextStyle value.
Example:
final style = TextStyle(
fontSize: 20,
fontStyle: FontStyle.italic,
fontWeight: FontWeight.bold,
letterSpacing: 2,
);
spot<Text>().withText('foo').existsOnce().hasEffectiveTextStyle(style);
See also:
- hasEffectiveTextStyleWhere, a matcher that performs specific assertions by applying a custom matcher function to TextStyle properties.
Implementation
WidgetMatcher<Text> hasEffectiveTextStyle(TextStyle? value) {
return hasEffectiveTextStyleWhere((it) {
if (value == null) {
it.isNull();
} else {
it.equals(value);
}
});
}