SensitiveContent class

Widget to set the ContentSensitivity of content in the widget tree.

The sensitivity of the widget in conjunction with the other SensitiveContent widgets in the tree will determine whether or not the screen will be obscured during media projection, e.g. screen sharing.

There are three ContentSensitivity levels, and these can be set via the SensitiveContent widget.

ContentSensitivity.sensitive is the highest prioritized setting, and if it is set, it will cause the tree to remain marked sensitive even if there are other SensitiveContent widgets in the tree.

ContentSensitivity.autoSensitive is the second most prioritized setting, and it will cause the tree to remain marked auto-sensitive if there are no sensitive SensitiveContent widgets elsewhere in the tree.

ContentSensitivity.notSensitive is the least prioritized setting, and it will cause the tree to remain marked auto-sensitive if there are no sensitive SensitiveContent widgets elsewhere in the tree. If there are no SensitiveContent widgets in the tree, the default setting as queried from the embedding will be used. This could be set by a Flutter developer in native Android; otherwise, Android uses ContentSensitivity.autoSensitive by default; see https://developer.android.com/reference/android/view/View#getContentSensitivity().

Currently, this widget is only supported on Android API 35+. On all lower Android versions and non-Android platforms, this does nothing; the screen will never be obscured regardless of the sensitivity set. To programmatically check if a device supports this widget, call SensitiveContentService.isSupported.

It is possible for a frame to be projected before the screen is updated to match the widget's sensitivityLevel, potentially revealing sensitive information during that frame. For example, when navigating from a page with no SensitiveContent to a new page in an app using a Navigator.of(context).pushReplacement to push a new PageRouteBuilder with (1) a pageBuilder that includes a SensitiveContent widget with sensitivity ContentSensitivity.sensitive and (2) transitionDuration: Duration.zero, one frame showing the app content is projected before the screen is obscured. See https://github.com/flutter/flutter/issues/164820 for for a discussion on known vulnerabilities or to report encountered vulnerabilities.

See also:

Inheritance

Constructors

SensitiveContent.new({Key? key, required ContentSensitivity sensitivity, required Widget child})
Creates a SensitiveContent widget.
const

Properties

child Widget
The child widget of this SensitiveContent.
final
hashCode int
The hash code for this object.
no setterinherited
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
sensitivity ContentSensitivity
The sensitivity that the SensitiveContent widget should sets for the Android native View hosting the widget tree.
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<SensitiveContent>
Creates the mutable state for this widget at a given location in the tree.
override
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited