Skip to content
Get started
Menu
Get started

Privacy mask

PrivacyMask hides what it wraps behind a plain surface and a lock icon while obscured is true. Use it for account numbers, identity details and balances that should not show in the app switcher or on a shared screen.

Decide when to obscure, usually from the app lifecycle. The mask covers the Flutter content only; it does not stop the operating system from capturing the screen, so add platform screenshot protection yourself.

Revealed virtual account reference beside the privacy lock control.Revealed virtual account reference beside the privacy lock control.
Light and dark variants
example/lib/adapters/synthetic_capture.dart
PrivacyMask(
obscured: obscured,
child: const Text('3100000000001234'),
);

Variants: visible, obscured.

The child stays laid out underneath, so nothing jumps when the mask lifts. The cover uses PaymentTheme.surface with a 48 px lock icon in textSecondary. The lock keeps 16 dp from the cover’s edges, and in a strip shorter than the icon it scales down instead of filling the strip.

Situation Variant / composition Payment example
App switcher protection obscured Cover sensitive screen content when the host says it is obscured.

Use masked text for NIK in review.

obscured: true covers the content and removes it from semantics. The host decides when sensitive content should be hidden.

Do: Cover sensitive screen content when the host says it is obscured.

Don’t: Claim PrivacyMask encrypts or persists data securely.

  • Mask whole blocks, not single digits. A half-covered number still leaks.
  • Unmask as soon as the app is active again. The mask is not a lock screen; it asks for nothing.
  • While obscured, the child is excluded from semantics and screen readers hear “Content hidden” instead.

PrivacyMask

class PrivacyMask extends StatelessWidget · lib/src/foundation/primitives.dart

Covers sensitive content when obscured is true, for example while the host app is in the app switcher. OS-level screenshot protection remains the host's responsibility.

ParameterTypeDefaultDescription
obscured:requiredbool——
child:requiredWidget——