A Flutter plugin for manipulating Android WindowManager LayoutParams dynamically at application run-time.
While Android natively supports a range of window modes, there was no
good way to set these dynamically within a running Flutter application -
instead requiring that these flags are set within the native
MainActivity of the Flutter application itself.
In our App, we only wished to disable screenshots for specific screens, rather than across the entire application lifecycle. This can now be accomplished by simply calling:
for the relevant screen.
This can further be toggled for a specific screen by either using a
RouteAware mixin, or through direct toggling in
dispose() methods in the case of stateful widgets.
The full range of LayoutParams flags are passed through. The plugin will carry out basic API level checking and throw an error on any unsupported flag specification. Flags are implemented using a bitmask, and may be specified individually or ORed together for setting/clearing multiple flags at once.
The current list of flags is:
In practice, this plugin was developed primarily for the toggling of
FLAG_SECURE. Other flags have not been tested, and we make no
guarantees that toggling with any of the other flags will interact well
with Flutter - if you find specific problems with any particular flag,
please let us know in the issue tracker.
flutter_windowmanager only wraps and exposes an underlying Android-specific
interface, there is no iOS support planned or possible. For those interested in
FLAG_SECURE functionality, this functionality has been re-created
in the third-party secure_application package. Cross-platform
functionality is provided by the third-party keep_screen_on package.
Features and bugs
Please file feature requests and bugs at the issue tracker.
Licensed under the terms of the Apache 2.0 license, the full version of which can be found in the LICENSE file included in the distribution.