Deprecate containsSemantics in favor of isSemantics
The `containsSemantics` matcher has been deprecated in favor of `isSemantics` and `matchesSemantics` matchers.
Summary
#
The containsSemantics partial matcher is deprecated and replaced by
isSemantics to clarify intent and standardize matcher conventions.
Context
#
The contains prefix for partial matchers, such as containsSemantics, has been
replaced with is to align with naming conventions:
-
Partial matchers (e.g.
isSemantics) match only the properties explicitly provided. Any arguments not provided are ignored. -
Exact matchers (e.g.
matchesSemantics) verify all values. Any arguments not provided are expected to match the object's default values.
Migration guide
#To automatically migrate your code, run the following command:
dart fix --apply
Alternatively, replace containsSemantics with isSemantics for partial
matching (most common case), or matchesSemantics if you need to assert
exact property values (including defaults for omitted arguments).
Code before migration:
expect(
tester.getSemantics(find.byType(MyWidget)),
containsSemantics(
label: 'My Widget',
isButton: true,
),
);
Code after migration:
expect(
tester.getSemantics(find.byType(MyWidget)),
isSemantics(
label: 'My Widget',
isButton: true,
),
);
Timeline
#Landed in version: 3.40.0-1.0.pre In stable release: 3.40
References
#API documentation:
Relevant issues:
Relevant PR:
Unless stated otherwise, the documentation on this site reflects Flutter 3.38.1. Page last updated on 2026-1-7. View source or report an issue.