flutter_windowmanager
a flutter plugin for manipulating android windowmanager layoutparams dynamically at application run-time.
motivation
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:
await flutterwindowmanager.addflags(flutterwindowmanager.flag_secure);
for the relevant screen.
this can further be toggled for a specific screen by either using a
routeaware mixin, or through direct toggling in initstate()
and
dispose()
methods in the case of stateful widgets.
flags
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:
flag_allow_lock_while_screen_on
flag_alt_focusable_im
flag_dim_behind
flag_force_not_fullscreen
flag_fullscreen
flag_hardware_accelerated
flag_ignore_cheek_presses
flag_keep_screen_on
flag_layout_inset_decor
flag_layout_in_screen
flag_layout_no_limits
flag_not_focusable
flag_not_touchable
flag_not_touch_modal
flag_scaled
flag_secure
flag_show_wallpaper
flag_split_touch
flag_watch_outside_touch
flag_blur_behind
flag_dismiss_keyguard
flag_dither
flag_draws_system_bar_backgrounds
flag_layout_attached_in_decor
flag_layout_in_overscan
flag_local_focus_mode
flag_show_when_locked
flag_touchable_when_waking
flag_translucent_navigation
flag_translucent_status
flag_turn_screen_on
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][tracker].
Comments are closed.