# Deprecate `containsSemantics` in favor of `isSemantics`

> The `containsSemantics` matcher has been deprecated in favor of `isSemantics` and `matchesSemantics` matchers.




:::important
These breaking change docs are accurate, as of the release
under which they are published. Over time, the
workarounds described here might become inaccurate.
We don't, in general, keep these breaking change docs up
to date as of each release.

这些破坏性改动文档的准确性仅限于其发布时对应的版本。
随着时间的推移，文档中描述的方案可能会逐渐失效。
通常情况下，我们不会在每次发布新版本时都对这些文档进行同步更新。

The [breaking change index file](/release/breaking-changes)
lists the docs created for each release.

[破坏性改动列表](/release/breaking-changes) 
列出了每个版本的文档。

:::


## 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** (such as `isSemantics`) match only
  the properties explicitly provided.
  Any arguments not provided are ignored.
* **Exact matchers** (such as `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:

```console
$ 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:

```dart
expect(
  tester.getSemantics(find.byType(MyWidget)),
  containsSemantics(
    label: 'My Widget',
    isButton: true,
  ),
);
```

Code after migration:

```dart
expect(
  tester.getSemantics(find.byType(MyWidget)),
  isSemantics(
    label: 'My Widget',
    isButton: true,
  ),
);
```

## Timeline

Landed in version: 3.40.0-1.0.pre<br>
In stable release: 3.41

## References

API documentation:

* [`isSemantics`][]
* [`matchesSemantics`][]

Relevant issues:

* [Issue 180534][]
* [Issue 107859][]

Relevant PR:

* [PR 180538][]

[`isSemantics`]: https://api.flutter-io.cn/flutter/flutter_test/isSemantics.html
[`matchesSemantics`]: https://api.flutter-io.cn/flutter/flutter_test/matchesSemantics.html
[Issue 180534]: https://github.com/flutter/flutter/issues/180534
[Issue 107859]: https://github.com/flutter/flutter/issues/107859
[PR 180538]: https://github.com/flutter/flutter/pull/180538

