Protect your app's sensitive content
This feature is available on Android API 35+, and you can try it out by using
the SensitiveContent
widget. See the guide below for details.
About the SensitiveContent
widget
#You can use the SensitiveContent
widget in your app to set the content
sensitivity of a child Widget
to one of the following ContentSensitivity
values: notSensitive
, sensitive
, or autoSensitive
. The mode that you
choose helps to determine if the device screen should be obscured
(blacked out) during media projection to protect users’ sensitive data.
You can have as many SensitiveContent
widgets in your app as you wish,
but if any one of those widgets has a sensitive
content value, then the
screen will be obscured during media projection. Thus, for most use cases,
using multiple SensitiveContent
widgets provides no advantage over having
one SensitiveContent
widget in your app’s widget tree. This feature is
available on Android API 35+ and has no effect on lower API versions and
other platforms.
Using the SensitiveContent
widget
#Given some content that you want to protect from media screen share
(for example, a MySensitiveContent()
widget), you can wrap it with the
SensitiveContent
widget as shown in the following example:
class MyWidget extends StatelessWidget {
...
Widget build(BuildContext context) {
return SensitiveContent(
sensitivity: ContentSensitivity.sensitive,
child: MySensitiveContent(),
);
}
}
When running on Android API 34 and below, the screen will not be obscured
during media projection. The widget will exist in the tree but has no other
effect, and you do not need to avoid usages of SensitiveContent
on platforms
that do not support this feature.
For more information
#For more information, visit the SensitiveContent
and ContentSensitivity
API docs.
除非另有说明,本文档之所提及适用于 Flutter 的最新稳定版本,本页面最后更新时间: 2025-08-26。 查看文档源码 或者 为本页面内容提出建议.