# Insert content text input client

> Add a new method to the TextInputClient interface to allow Android virtual keyboards to insert rich content into Flutter TextFields.




:::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

Added an `insertContent` method to the `TextInputClient` interface to
allow Android's image keyboard feature to
insert content into a Flutter `TextField`.

## Context

As of Android 7.1, IMEs (input method editors or virtual keyboards) can send
images and rich content into a text editor.
This allows users to insert gifs, stickers, or
context-aware rich content into a text field.

## Description of change

When the user inserts rich content in the IME, the platform
sends a `TextInputClient.commitContent` channel message,
notifying the Dart code that the IME inserted rich content.
The channel message contains the mime type, URI, and bytedata for
the inserted content in JSON form.

## Migration guide

If you implemented the `TextInputClient` interface earlier, override
`insertContent` to either support rich content insertion
or provide an empty implementation.

To migrate, implement `insertContent`.

Code before migration:

```dart
class MyCustomTextInputClient implements TextInputClient {
  // ...
}
```

Code after migration:

```dart
class MyCustomTextInputClient implements TextInputClient {
  // ...
  @override
  void insertContent() {
    // ...
  }
  // ...
}
```

Your implementation of `TextInputClient` might not require
the ability to receive rich content inserted from the IME.
In that case, you can leave the implementation of
`insertContent` empty with no consequences.

```dart
class MyCustomTextInputClient implements TextInputClient {
  // ...
  @override
  void insertContent() {}
  // ...
}
```

As an alternative, you can use a similar implementation to
the default `TextInputClient`.
To learn how to do this, check out the [insertContent implementation][].

To prevent breaking changes to an interface,
use `with TextInputClient` rather than `implements TextInputClient`.

[insertContent implementation]: https://api.flutter-io.cn/flutter/services/TextInputClient/insertContent.html

## Timeline

Landed in version: 3.8.0-1.0.pre<br>
In stable release: 3.10.0

## References

API documentation:

* [`TextInputClient`](https://api.flutter-io.cn/flutter/services/TextInputClient-class.html)

Relevant issue:

* [Issue 20796](https://github.com/flutter/flutter/issues/20796)

Relevant PRs:

* [24224: Support Image Insertion on Android (engine)](https://github.com/flutter/engine/pull/35619)
* [97437: Support Image Insertion on Android](https://github.com/flutter/flutter/pull/110052)

