A Flutter plugin for manipulating Android WindowManager LayoutParams.

Overview

flutter_windowmanager

Build Status Pub

A Flutter plugin for manipulating Android WindowManager LayoutParams dynamically at application run-time.

Example App Use

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.

iOS Support

As flutter_windowmanager only wraps and exposes an underlying Android-specific interface, there is no iOS support planned or possible. For those interested in cross-platform FLAG_SECURE functionality, this functionality has been re-created in the third-party secure_application package. Cross-platform FLAG_KEEP_SCREEN_ON functionality is provided by the third-party keep_screen_on package.

Features and bugs

Please file feature requests and bugs at the issue tracker.

License

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.

Comments
  • flutter_windowmanager has been deprecated, need to update as per latest flutter version

    flutter_windowmanager has been deprecated, need to update as per latest flutter version

    Getting below error in console panel:

    The plugins `flutter_windowmanager` use a deprecated version of the Android embedding.
    To avoid unexpected runtime failures, or future build failures, try to see if these plugins support the Android V2 embedding. Otherwise, consider removing them since a future release of Flutter will remove these deprecated APIs.
    

    Need to update flutter_windowmanager plugin as per latest flutter version. Thanks.

    opened by kamleshwebtech 6
  • Black Screen when using flutter_windowmanager with flutter_pdfview in oppo devices only

    Black Screen when using flutter_windowmanager with flutter_pdfview in oppo devices only

    I am using flutter_pdfview package I found a black screen with it in oppo devices only , in all other devices it works perfectly.

    dependencies: flutter_pdfview: ^1.0.4 flutter_windowmanager: ^0.0.2

    Function which called in main() to apply on the whole app Future secure() async { await FlutterWindowManager.addFlags(FlutterWindowManager.FLAG_SECURE); }

    This is my flutter doctor -v

    [√] Flutter (Channel unknown, 1.22.1, on Microsoft Windows [Version 10.0.19042.867], locale en-US)
        • Flutter version 1.22.1 at C:\flutter
        • Framework revision f30b7f4db9 (6 months ago), 2020-10-08 10:06:30 -0700
        • Engine revision 75bef9f6c8
        • Dart version 2.10.1
    
     
    [√] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
        • Android SDK at C:\Users\abas\AppData\Local\Android\sdk
        • Platform android-30, build-tools 30.0.2
        • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
        • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
        • All Android licenses accepted.
    
    [!] Android Studio (not installed)
        • Android Studio not found; download from https://developer.android.com/studio/index.html
          (or visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions).
    PS C:\Users\abas\Documents\GitHub\online_education> flutter doctor -v
    [√] Flutter (Channel unknown, 1.22.1, on Microsoft Windows [Version 10.0.19042.867], locale en-US)
        • Flutter version 1.22.1 at C:\flutter
        • Framework revision f30b7f4db9 (6 months ago), 2020-10-08 10:06:30 -0700
        • Engine revision 75bef9f6c8
        • Dart version 2.10.1
    
    
    [√] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
        • Android SDK at C:\Users\abas\AppData\Local\Android\sdk
        • Platform android-30, build-tools 30.0.2
        • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
        • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
        • All Android licenses accepted.
    
    [!] Android Studio (not installed)
        • Android Studio not found; download from https://developer.android.com/studio/index.html
          (or visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions).
    
    [√] VS Code (version 1.55.1)
        • VS Code at C:\Users\abas\AppData\Local\Programs\Microsoft VS Code
        • Flutter extension version 3.21.0
    
    [√] Connected device (2 available)
        • CPH1911 (mobile)            • LBBQSCQCKRIZTC4H • android-arm64 • Android 10 (API 29)
        • sdk gphone x86 arm (mobile) • emulator-5554    • android-x86   • Android 11 (API 30) (emulator)
    
    ! Doctor found issues in 1 category.
    
    opened by Zeyad-Amr 6
  • Cannot able to prevent screenshots in the specific screen

    Cannot able to prevent screenshots in the specific screen

    I added this plugin in the specific screen of my app where I want to disable the screenshot. But my whole app gets disable t get the screenshot. I added the in the below way, don't where i am getting wrong.

    Added the Code:

    pubspec.yaml flutter_windowmanager: ^0.0.2

    class PreventScreenShot extends StatefulWidget {
      PreventScreenShot({Key key}) : super(key: key);
    
      @override
      _PreventScreenShotState createState() => _PreventScreenShotState();
    }
    
    class _PreventScreenShotState extends State<PreventScreenShot> {
    
      Future _flagSecure() async {
        await FlutterWindowManager.addFlags(FlutterWindowManager.FLAG_SECURE);
      }
    
      Future _clearFlags() async {
        await FlutterWindowManager.clearFlags(FlutterWindowManager.FLAG_SECURE);
      }
    
      @override
      void initState() { 
        super.initState();
        _flagSecure();
      }
    
      @override
      void dispose() {
        // TODO: implement dispose
        super.dispose();
        _clearFlags();
      }
    
    
      @override
      Widget build(BuildContext context) {
        return Scaffold(
              body: Center(
             child: Text("Testing"),
          ),
        );
      }
    }
    
    opened by yash365 4
  • Screen recording not blocked in Android 11

    Screen recording not blocked in Android 11

    So I started using this package around last week, and it works fine: screenshot is blocked, and the screen turned black when screen recording. However, today I tried it again and my app's screen no longer turns black when being recorded. The only difference I had in my phone is that it was updated to Android 11, even though I'm not sure if that's the case. Anyone else have the same issue? The device I use is Samsung Galaxy S10.

    opened by HCID-SMART 2
  • FlutterWindowManager.FLAG_SECURE

    FlutterWindowManager.FLAG_SECURE

    await FlutterWindowManager.addFlags(FlutterWindowManager.FLAG_SECURE);

    not able to prevent screen video recorder using this..(tested using DU Recorder)

    opened by Bharavi26 2
  • Unhandled Exception: MissingPluginException(No implementation found for method addFlags on channel flutter_windowmanager)

    Unhandled Exception: MissingPluginException(No implementation found for method addFlags on channel flutter_windowmanager)

    Restarted application in 10,507ms. E/flutter (15958): [ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: MissingPluginException(No implementation found for method addFlags on channel flutter_windowmanager) E/flutter (15958): #0 MethodChannel._invokeMethod package:flutter/…/services/platform_channel.dart:165 E/flutter (15958): E/flutter (15958): #1 FlutterWindowManager.addFlags (package:flutter_windowmanager/flutter_windowmanager.dart:111:12) E/flutter (15958): E/flutter (15958): #2 main package:myproject/main.dart:22 E/flutter (15958): E/flutter (15958):

    opened by priyaranjan-mantri 1
  • How to prohibit maximize window by double clicking toolbar or area within

    How to prohibit maximize window by double clicking toolbar or area within "DragToMoveArea"?

    I want to prevent user to resize app, my main code like this :

    void main() async {
      WidgetsFlutterBinding.ensureInitialized();
    
      if (Platform.isWindows) {
        await WindowManager.instance.ensureInitialized();
        windowManager.waitUntilReadyToShow().then((_) async {
          await windowManager.setTitleBarStyle(
            TitleBarStyle.hidden,
            windowButtonVisibility: false,
          );
          await windowManager.setSize(const Size(755, 545));
          await windowManager.setMinimumSize(const Size(755, 545));
          await windowManager.setPreventClose(true);
          await windowManager.setSkipTaskbar(false);
          await windowManager.setResizable(false);
          await windowManager.setMinimizable(true);
          await windowManager.center();
          await windowManager.focus();
          await windowManager.show();
        });
      }
    ...
    

    And my home page is wrapped within "DragToMoveArea". But the app can still be maximized by double clicking any area of the page.

    opened by dbsxdbsx 1
  • flutter embedding v2 migration

    flutter embedding v2 migration

    Migrate to flutter embedding v2. fixes #17

    • https://flutter.dev/docs/development/packages-and-plugins/plugin-api-migration
    • https://github.com/flutter/flutter/wiki/Upgrading-pre-1.12-Android-projects

    It looks like there was an attempt in https://github.com/adaptant-labs/flutter_windowmanager/commit/0a3e2cad3c122e5b12f16d82b3f0c3a97cbeb4d0 but this only touched on the example app, not the plugin. and the only thing related to v2 embedding was the introduction of the meta-data in the AndroidManifest.xml, nothing else.

    opened by hpoul 1
  • Migrate to Android V2 embedding

    Migrate to Android V2 embedding

    With the latest flutter (dev) channel the following warning is shown. I guess it would be time to migrate to the new embedding apis. If this project is still maintained i can try to create a PR?

    Running "flutter pub get" in authpass...                         2,069ms
    The plugin `flutter_windowmanager` uses a deprecated version of the Android embedding.
    To avoid unexpected runtime failures, or future build failures, try to see if this plugin supports the Android V2 embedding.
    Otherwise, consider removing it since a future release of Flutter will remove these deprecated APIs.
    If you are plugin author, take a look at the docs for migrating the plugin to the V2 embedding:
    https://flutter.dev/go/android-plugin-migration.
    
    opened by hpoul 1
  • Added support to null safety. Fixes #13.

    Added support to null safety. Fixes #13.

    I was using this package in an app I'm just porting to Flutter 2.2. I'm not used to write plugins nor MethodChannels, but thanks to the unit tests I believe I added support to null safety in this package.

    I'd like to propose this fix for evaluation and merge it, if that is useful.

    opened by CarlosNihelton 1
  • A problem occurred configuring project ':flutter_windowmanager'.

    A problem occurred configuring project ':flutter_windowmanager'.

    Unexpected lock protocol found in lock file. Expected 3, found 0. Could not get unknown property 'android' for project ':flutter_windowmanager' of type org.gradle.api.Project.

    opened by arunsacharyadev 1
  • deprecation API

    deprecation API

    this happen when run this command flutter build apk --profile

    **

    flutter.pub-cache\hosted\pub.dartlang.org\flutter_windowmanager-0.2.0\android\src\main\java\io\adaptant\labs\flutter_windowmanager\FlutterWindowManagerPlugin.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details.

    **

    opened by hamidwaezi 0
  • this model don't Support

    this model don't Support

      await FlutterWindowManager.addFlags(  FlutterWindowManager.FLAG_SHOW_WHEN_LOCKED );
    

    Hi, I am trying to enable this permission on my Xiaomi Android Phone, but I get this in my terminal log

    W/MirrorManager(  514): this model don't Support
    

    Can anyone guide me how can I solve this error or any other by to enable these two permission

    1). Display pop-up windows while running in the background 2). Show on lock screen

    Flutter 3.0.5 Tools • Dart 2.17.6 • DevTools 2.12.2

    opened by osamasaeed 0
  • No implementation found for method addFlags

    No implementation found for method addFlags

    [ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: MissingPluginException(No implementation found for method addFlags on channel flutter_windowmanager)

    opened by OmarBlancko 2
  • Adjust iOS Plugin return code to fail silently

    Adjust iOS Plugin return code to fail silently

    The return type of the FlutterWindowManager.addFlags(FlutterWindowManager.FLAG_SECURE) function is Future<bool>, which is just bubbling up the value from the method channel. This is great on Android, but on iOS, the method channel returns a string of the iOS version from boilerplate plugin code. At runtime, if the addFlags function is invoked in iOS, an exception is thrown because of invalid type coercion.

    The obvious workaround is to only invoke the function if Flutter detects Platform.isAndroid, but this is not intuitive nor represented in documentation.

    I suggest modifying the iOS plugin code to invoke the result function with value false.

    opened by alkamike 0
Releases(v0.2.0)
Owner
Adaptant Labs
Adaptive Data Privacy Technology and Compliance Solutions
Adaptant Labs
Permission plugin for Flutter. This plugin provides a cross-platform (iOS, Android) API to request and check permissions.

Flutter permission_handler plugin The Flutter permission_handler plugin is build following the federated plugin architecture. A detailed explanation o

Baseflow 1.7k Dec 31, 2022
Klutter plugin makes it possible to write a Flutter plugin for both Android and iOS using Kotlin only.

The Klutter Framework makes it possible to write a Flutter plugin for both Android and iOS using Kotlin Multiplatform. Instead of writing platform spe

Gillian 33 Dec 18, 2022
Flutter plugin (android) for sharing bytes and files Offline, (Based on the android Nearby Connections API)

nearby_connections An android flutter plugin for the Nearby Connections API Currently supports Bytes and Files. Transfer Data between multiple connect

Prerak Mann 63 Nov 21, 2022
This is just the simplyfied Flutter Plugin use for one of the popular flutter plugin for social media login.

social_media_logins Flutter Plugin to login via Social Media Accounts. Available Social Media Logins: Facebook Google Apple Getting Started To use thi

Reymark Esponilla 3 Aug 24, 2022
Unloc customizations of the Permission plugin for Flutter. This plugin provides an API to request and check permissions.

Flutter Permission handler Plugin A permissions plugin for Flutter. This plugin provides a cross-platform (iOS, Android) API to request and check perm

Unloc 1 Nov 26, 2020
A Flutter step_tracker plugin is collect information from user and display progress through a sequence of steps. this plugin also have privilege for fully customization from user side. like flipkart, amazon, myntra, meesho.

step_tracker plugin A Flutter step_tracker plugin is collect information from user and display progress through a sequence of steps. this plugin also

Roshan nahak 5 Oct 21, 2022
Flutter simple image crop - A simple and easy to use flutter plugin to crop image on iOS and Android

Image Zoom and Cropping plugin for Flutter A simple and easy used flutter plugin to crop image on iOS and Android. Installation Add simple_image_crop

null 97 Dec 14, 2021
Flutter blue plus - Flutter plugin for connecting and communicationg with Bluetooth Low Energy devices, on Android and iOS

Introduction FlutterBluePlus is a bluetooth plugin for Flutter, a new app SDK to

null 141 Dec 22, 2022
Flutter plugin for selecting images from the Android and iOS image library, taking new pictures with the camera, and edit them before using such as rotation, cropping, adding sticker/text/filters.

advance_image_picker Flutter plugin for selecting multiple images from the Android and iOS image library, taking new pictures with the camera, and edi

Weta Vietnam 91 Dec 19, 2022
A Flutter plugin integrated with Android-SerialPort-API

A Flutter plugin integrated with Android-SerialPort-API.

null 1 Nov 10, 2021
Flutter Local Notifications - Learn how to implement local notifications into both Android and iOS using flutter_local_notifications plugin.

Flutter Local Notifications Example Flutter Local Notifications - Learn how to implement local notifications into both Android and iOS using flutter_l

Sandip Pramanik 12 Nov 29, 2022
A Flutter plugin that provides assets abstraction management APIs without UI integration, you can get assets (image/video/audio) on Android, iOS and macOS.

photo_manager Photo/Assets management APIs for Flutter without UI integration, you can get assets (image/video/audio) from Android, iOS and macOS. 提供相

FlutterCandies 526 Jan 4, 2023
A Flutter Plugin for Volume Control and Monitoring, support iOS and Android

flutter_volume A flutter plugin for volume control and monitoring, support iOS and Android 手把手带你写 Flutter 系统音量插件 https://www.yuque.com/befovy/share/fl

befovy 35 Dec 9, 2022
A Flutter plugin for changing the Home Screen, Lock Screen (or both) Wallpaper on Android devices.

wallpaper_manager A Flutter plugin for changing the Home Screen, Lock Screen (or both) Wallpaper(s) on Android devices. Usage Installation In the pubs

Aditya Mulgundkar 38 Nov 28, 2022
A flutter plugin to crop image on iOS and Android.

Image Cropping plugin for Flutter A flutter plugin to crop image on iOS and Android. The plugin comes with a Crop widget. The widget renders only imag

Volodymyr Lykhonis 292 Dec 27, 2022
A Flutter plugin for IOS and Android providing a simple way to display PDFs.

Pdf Viewer Plugin A Flutter plugin for IOS and Android providing a simple way to display PDFs. Features: Display PDF. Installation First, add pdf_view

Lucas Britto 56 Sep 26, 2022
A Flutter plugin for authenticating users by using the native TwitterKit SDKs on Android & iOS.

flutter_twitter_login A Flutter plugin for using the native TwitterKit SDKs on Android and iOS. This plugin uses the new Gradle 4.1 and Android Studio

Iiro Krankka 83 Sep 15, 2022
A flutter plugin for viewing PDF files in mobile app (Android & iOS)

PDF Viewer (JK) A flutter plugin for viewing PDF files in mobile app (Android & iOS) Pub.dev https://pub.dev/packages/pdf_viewer_jk Github ht

Jawad 8 Sep 30, 2021