# Migration guide for ignoringSemantics in IgnorePointer and related classes

> Removal of ignoringSemantics in IgnorePointer and related classes.




:::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 `IgnoringPointer` widget allows you to designate an area of the UI
where you don't want to accept pointer events, for example, when
you don't want to allow the user to enter text in a text field.

Previously, the `IgnorePointer` not only blocked pointer events but also
dropped its subtree from the semantics tree. The `ignoreSemantics` parameter
was introduced as a workaround to preserve the semantics tree when using
`IgnorePointer`s.

The `IgnorePointer` behavior has changed in that it no longer drops
the entire semantics subtree but merely blocks semantics actions in the
subtree. The `ignoringSemantics` workaround is no longer needed and is
deprecated.

This change also applies to the `AbsorbPointer` and
`SliverIgnorePointer` widgets.

## Description of change

`ignoringSemantics` was removed.

## Migration guide

If you set this parameter to true in these widgets, consider using
`ExcludeSemantics` instead.

Code before migration:

```dart
IgnorePointer(
  ignoringSemantics: true,
  child: const PlaceHolder(),
);

AbsorbPointer(
  ignoringSemantics: true,
  child: const PlaceHolder(),
);

SliverIgnorePointer(
  ignoringSemantics: true,
  child: const PlaceHolder(),
);
```

Code after migration:

```dart
ExcludeSemantics(
  child: IgnorePointer(
    child: const PlaceHolder(),
  ),
);

ExcludeSemantics(
  child: AbsorbPointer(
    child: const PlaceHolder(),
  ),
);

SliverIgnorePointer(
  child: ExcludeSemantics(
    child: const PlaceHolder(),
  ),
);
```

If you are previously using `IgnorePointer`s with `ignoringSemantics` set to `false`,
you can achieve the same behavior by copying the follow widgets directly into your
code and use.

```dart
/// A widget ignores pointer events without modifying the semantics tree.
class _IgnorePointerWithSemantics extends SingleChildRenderObjectWidget {
  const _IgnorePointerWithSemantics({
    super.child,
  });

  @override
  _RenderIgnorePointerWithSemantics createRenderObject(BuildContext context) {
    return _RenderIgnorePointerWithSemantics();
  }
}

class _RenderIgnorePointerWithSemantics extends RenderProxyBox {
  _RenderIgnorePointerWithSemantics();

  @override
  bool hitTest(BoxHitTestResult result, { required Offset position }) => false;
}

/// A widget absorbs pointer events without modifying the semantics tree.
class _AbsorbPointerWithSemantics extends SingleChildRenderObjectWidget {
  const _AbsorbPointerWithSemantics({
    super.child,
  });

  @override
  _RenderAbsorbPointerWithSemantics createRenderObject(BuildContext context) {
    return _RenderAbsorbPointerWithSemantics();
  }
}

class _RenderAbsorbPointerWithSemantics extends RenderProxyBox {
  _RenderAbsorbPointerWithSemantics();

  @override
  bool hitTest(BoxHitTestResult result, { required Offset position }) {
    return size.contains(position);
  }
}

/// A sliver ignores pointer events without modifying the semantics tree.
class _SliverIgnorePointerWithSemantics extends SingleChildRenderObjectWidget {
  const _SliverIgnorePointerWithSemantics({
    super.child,
  });

  @override
  _RenderSliverIgnorePointerWithSemantics createRenderObject(BuildContext context) {
    return _RenderSliverIgnorePointerWithSemantics();
  }
}

class _RenderSliverIgnorePointerWithSemantics extends RenderProxySliver {
  _RenderSliverIgnorePointerWithSemantics();

  @override
  bool hitTest(BoxHitTestResult result, { required Offset position }) => false;
}
```

## Timeline

Landed in version: 3.10.0-2.0.pre<br>
In stable release: 3.13.0

## References

Relevant PRs:

* [PR 120619][]: Fixes IgnorePointer and AbsorbPointer to only block user
  interactions in a11y.

[PR 120619]: https://github.com/flutter/flutter/pull/120619
[`IgnorePointer`]: https://api.flutter-io.cn/flutter/widgets/IgnorePointer-class.html
[`AbsorbPointer`]: https://api.flutter-io.cn/flutter/widgets/AbsorbPointer-class.html
[`SliverIgnorePointer`]: https://api.flutter-io.cn/flutter/widgets/SliverIgnorePointer-class.html
[`RenderSliverIgnorePointer`]: https://api.flutter-io.cn/flutter/rendering/RenderSliverIgnorePointer-class.html
[`RenderIgnorePointer`]: https://api.flutter-io.cn/flutter/rendering/RenderIgnorePointer-class.html
[`RenderAbsorbPointer`]: https://api.flutter-io.cn/flutter/rendering/RenderAbsorbPointer-class.html

