GithubHelp home page GithubHelp logo

jiusanzhou / flutter_floatwing Goto Github PK

View Code? Open in Web Editor NEW
165.0 4.0 26.0 8.09 MB

A Flutter plugin that makes it easier to make floating/overlay window for Android with pure Flutter. 一个可以用纯粹的Flutter来开发Android浮动窗口的插件。

License: Other

Kotlin 45.73% Dart 54.27%
overlay android flutter floating-window flutter-plugin overlay-window alert-widget background-service display-over-other-apps popup-window

flutter_floatwing's Introduction

Hi there 👋, I'm Zoe.

Here are some information about me:

Readme Stat Top Lang

flutter_floatwing's People

Contributors

jiusanzhou avatar psovit avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

flutter_floatwing's Issues

在window里start一个新的window不成功

创建了一个window 然后类似demo里的AssistiveTouch一样 希望能再创建一个新的window
但是在初始化新的window的时候,整个应用的初始又全部重新走了一遍(应用没有重新启动之类的视觉上的变化,是全部相关的日志重新输出了)
然后start之后也没有任何反应

Compiling error

flutter_floatwing-main\android\src\main\kotlin\im\zoe\labs\flutter_floatwing\FloatwingService.kt: (128, 32): Type mismatch: inferred type is Map<*, >? but Map<, *> was expected

Open is not clickable "nulled"

i tried installing the package and i gave it permissions
but i do not know why is Open button non clickable

it seems it always return null
because the window i thinks is never ready

i cloned the package and it did work greatly

but when i set it in a new project that problem occur
am i messing something to add so that the w is ready ?

sorry it worked

Can not work fine with some plugin which calling dart from Android.

This may be a common issue. Plugins register method channels and message channels in onAttachEngine, While the window engine started, those channels will be registered again. That will cause the call from the main engine(the app) missing response.

Known issues: #6

Currently I don't know how to handle this issue. Discussion is welcome!

Error in debug mode and no response to anything

../../../flutter/.pub-cache/hosted/pub.dartlang.org/flutter_floatwing-0.2.0/lib/src/provider.dart:143:30: Warning: Operand of null-aware operation '?.' has type 'SchedulerBinding' which excludes null.

  • 'SchedulerBinding' is from 'package:flutter/src/scheduler/binding.dart' ('../../../flutter/packages/flutter/lib/src/scheduler/binding.dart').
    SchedulerBinding.instance?.addPostFrameCallback(postFrameCallback);
    20220706-errors

Screen shows a scrollable windows, but appears to not respond to anything.
flutter_01

Flutter 3.0.3 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 676cefaaff (13 days ago) • 2022-06-22 11:34:49 -0700
Engine • revision ffe7b86a1e
Tools • Dart 2.17.5 • DevTools 2.12.2

Flutter Doctor: all ok

EventType.WindowDestroy returned data is null

The WindowDestroy event which gets called when closing a window is not returning any value in the data i.e. forceClose value.

I am listening to the event in this manner:
_window?.on(EventType.WindowDestroy, (Window window, dynamic data)

The event call gets notified but data is empty.

Also seeing an error in the console:

W/FlutterJNI(17960): Tried to send a platform message to Flutter, but FlutterJNI was detached from native C++. 
Could not send. Channel: im.zoe.labs/flutter_floatwing/window_msg. Response ID: 9

inactive button

I tried to use your example code, but when I run it I can't press 'Open' (inactive). Any suggestions on this, or some kind of video tutorial for using your package?

Screen Shot 2022-06-06 at 09 58 34

Need support for higher Kotlin Gradle version

  • What went wrong:
    The Android Gradle plugin supports only Kotlin Gradle plugin version 1.5.20 and higher.
    The following dependencies do not satisfy the required version:
    project ':flutter_floatwing' -> org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.50

Cannot `start` Window with `entry-point`

Thanks for the great package!

Specs:

Flutter: 3.3.10 (stable)
Android SDK: 31.0.0-rc4
flutter_floatwing: ^0.2.1

Issue:

I'm trying to run a simple test, where I show an overlay with the entry-point. But the window doesn't start/create, instead null is returned. The followings are the logs -

Logs
Launching lib\main.dart on Android SDK built for x86 in debug mode...
lib\main.dart:1
√  Built build\app\outputs\flutter-apk\app-debug.apk.
Connecting to VM Service at ws://127.0.0.1:61440/5XyFBiJrhLk=/ws
D/FloatwingPlugin( 9392): [plugin] pixel radio already exits
D/FloatwingPlugin( 9392): [plugin] system config already exits: {"pixelRadio":2,"screen":{"width":1080,"height":2208}}
[log] [plugin] initialize result: {permission_grated: true, pixel_radio_updated: false, system_config_updated: false, service_running: false, windows: null}
[log] [plugin] there are 0 windows already started
D/FloatwingService( 9392): [service] wait for service created
I/FloatwingService( 9392): [service] create a window: default {entry=myOverlayMain}
D/FloatwingService( 9392): [service] wait for service created
I/flutter ( 9392): [ DEBUG ]: window null

I also noticed that awaiting the openPermissionSetting() doesn't actually wait for permission from the user/settings.

await FloatwingPlugin().openPermissionSetting();

Steps to reproduce:

Run the following code -

main.dart
import 'package:flutter/material.dart';
import 'package:flutter_floatwing/flutter_floatwing.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  FloatwingPlugin().initialize();
  runApp(const RootApp());
}

@pragma("vm:entry-point")
void myOverlayMain() {
  WidgetsFlutterBinding.ensureInitialized();
  runApp(
    MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Material(
        color: Colors.transparent,
        elevation: 0.0,
        child: Container(
          width: 100,
          height: 100,
          color: Colors.black,
        ),
      ),
    ),
  );
}

class RootApp extends StatelessWidget {
  const RootApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        appBar: AppBar(
          title: const Text("Floatwing Test"),
        ),
        body: Center(
          child: TextButton(
            onPressed: _startWindow,
            child: const Text("Start"),
          ),
        ),
      ),
    );
  }

  void _startWindow() async {
    // check permission and service status
    final bool hasPermission = await FloatwingPlugin().checkPermission();
    final bool serviceStarted = await FloatwingPlugin().isServiceRunning();

    if (!hasPermission) {
      await FloatwingPlugin().openPermissionSetting();
      // ☝️ it doesn't wait for the value returned by permissions
    }
    if (!serviceStarted) {
      await FloatwingPlugin().startService();
    }

    // start overlay window
    final Window? window = await WindowConfig(
      entry: "myOverlayMain",
    ).to().create(start: true);

    debugPrint("[ DEBUG ]: window $window");
  }
}

issues when developing

2020.01.02 or some days

  • start project and research

2022.05.10 and before fews days

  1. implement first
  2. imporve code style
  3. manage multi windows

2022.05.11

  1. auto adjust window size not works
  2. back action not works
  3. Window.of(context) can't take value
  4. drag implement
  5. auto size not smooth
  6. enum special size and gravity
  7. share data from main with window
  8. gravity to arround
  9. use message channel for events instead of metho channel
  10. annimation
  11. resizable
  12. multi windows message channel handle wrong

2022.05.12

  • define event name
  • send system config from main to windows
  • support Widget class as entrypoint

2022.05.13

  • comments, add readme and docs
  • iOS style assitive touch example
  • support static function as entrypoint
  • make provider widget to extensions
  • make window engine can manage other windows
  • permance event only registed event can be emit
  • events isolate: a) main engine can comsume from all, b) parent can comsume children
  • plugin add static on to listen event from all windows

2022.05.14

  • add drag slot widget in flutter
  • add hook point for windows lifecycle and other else

2022.05.16

  • change config more flutter way
  • event publish from window engine
  • result.error to return error in method channel

使用flutter 3.7.5运行example点击assitive_touch出现异常。

flutter doctor -v
Flutter assets will be downloaded from https://mirror.sjtu.edu.cn. Make sure you trust this source!
[✓] Flutter (Channel stable, 3.7.5, on Microsoft Windows [版本 10.0.22621.1265], locale en-US)
• Flutter version 3.7.5 on channel stable at D:\Github\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision c07f788888 (2 days ago), 2023-02-22 17:52:33 -0600
• Engine revision 0f359063c4
• Dart version 2.19.2
• DevTools version 2.20.1
• Pub download mirror https://mirror.sjtu.edu.cn/dart-pub
• Flutter download mirror https://mirror.sjtu.edu.cn
点击assitive_touch出现异常。
PlatformException (PlatformException(error, java.lang.Long cannot be cast to java.lang.Integer, null, java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.Integer
at im.zoe.labs.flutter_floatwing.FloatWindow$Config$Companion.from(FloatWindow.kt:502)
at im.zoe.labs.flutter_floatwing.FloatWindow.onMethodCall(FloatWindow.kt:221)
at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:258)
at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295)
at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$DartMessenger(DartMessenger.java:322)
at io.flutter.embedding.engine.dart.-$$Lambda$DartMessenger$2j2MERcK825A5j1fv5sZ7xB2Iuo.run(lambda)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6197)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:892)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:782)
))

无法获取window

你好,我的App通过entry-point方式开启悬浮窗,悬浮窗包含在GetMaterialApp中。
在悬浮窗的SchedulerBinding.instance.addPostFrameCallback调用Window.of(context)和FloatwingPlugin().currentWindow都返回null。
调用syncWindows()后再通过windows["xxxID"]可以获取window对象,但不会回调onData。

版本信息
flutter_floatwing: ^0.2.1
Flutter: 3.0.5

In release mode, an error occurs while using `non-main` entry

In release mode, an error occurs,

E/flutter (17069): [ERROR:flutter/shell/common/shell.cc(93)] Dart Unhandled Exception: NoSuchMethodError: No top-level getter 'androidWindow' declared.
E/flutter (17069): Receiver: top-level
E/flutter (17069): Tried calling: androidWindow, stack trace: #0 NoSuchMethodError._throwNew (dart:core-patch/errors_patch.dart:222)
E/flutter (17069):
E/flutter (17069): [ERROR:flutter/runtime/dart_isolate.cc(681)] Could not resolve main entrypoint function.
E/flutter (17069): [ERROR:flutter/runtime/dart_isolate.cc(165)] Could not run the run main Dart entrypoint.
E/flutter (17069): [ERROR:flutter/runtime/runtime_controller.cc(381)] Could not create root isolate.
E/flutter (17069): [ERROR:flutter/shell/common/shell.cc(580)] Could not launch engine with configuration.

MissingPluginException while running Demo

Hi,I have a problem running the application
E/flutter (18685): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: MissingPluginException(No implementation found for method window.start on channel im.zoe.labs/flutter_floatwing/window) E/flutter (18685): #0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:175:7) E/flutter (18685): <asynchronous suspension> E/flutter (18685): #1 Window.start (package:flutter_floatwing/src/window.dart:114:12) E/flutter (18685): <asynchronous suspension> E/flutter (18685):

Can't run example app

Hi, great package!

I tried to run the example app and couldn't run it. So I've decided to create a minimal app based on the docs but couldn't run either.

I'm using the views for example folder and this is the code that I'm using for the main app

import 'package:floating_app/views/night.dart';
import 'package:floating_app/views/normal.dart';
import 'package:flutter/material.dart';
import 'package:flutter_floatwing/flutter_floatwing.dart';

import 'views/assistive_touch.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      routes: {
        '/': (_) => const MyHomePage(title: 'Flutter Demo Home Page'),
        '/normal': (_) => NormalView(),
        '/night': (_) => NightView(),
        '/assistive': (_) => AssistiveTouch(),
      },
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key, required this.title}) : super(key: key);

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  void initState() {
    super.initState();
    FloatwingPlugin().checkPermission().then((v) {
      if (!v) FloatwingPlugin().openPermissionSetting();
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      floatingActionButton: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          FloatingActionButton(
            onPressed: () async => initializeSerices(),
            tooltip: 'Increment',
            child: const Icon(Icons.play_arrow),
          ),
          FloatingActionButton(
            onPressed: () async => _createWindow(),
            tooltip: 'Increment',
            child: const Icon(Icons.add),
          ),
          FloatingActionButton(
            onPressed: () async => _createWindow2(),
            tooltip: 'Increment',
            child: const Icon(Icons.minimize),
          ),
        ],
      ), // This trailing comma makes auto-formatting nicer for build methods.
    );
  }

  Future<void> initializeSerices() async {
    await FloatwingPlugin().initialize();

    await FloatwingPlugin().isServiceRunning().then((v) async {
      await FloatwingPlugin().startService().then((_) {
        print("start the backgroud service success.");
      });
    });
  }

  Future<void> _createWindow() async {
    final window = await WindowConfig(id: 'test2', route: '/normal')
        .to()
        .on(EventType.WindowCreated, (w, _) {
      print('TEST');
    }).create(start: true);
  }

  Future<void> _createWindow2() async {
    final windows = FloatwingPlugin().windows;
    final window = await WindowConfig(
      id: 'test2',
      entry: null,
      callback: myOverlayMain,
    ).create(start: true);
  }
}

void myOverlayMain() {
  runApp(((_) => NormalView()).floatwing(app: true).make());
}

If I click in the play button, then plus, then minimize, these are the logs that I'm getting:

D/FloatwingPlugin( 9657): [plugin] pixel radio already exits
D/FloatwingPlugin( 9657): [plugin] system config already exits: {"pixelRadio":2,"screen":{"width":1080,"height":1794}}
[log] [plugin] initialize result: {permission_grated: true, pixel_radio_updated: false, system_config_updated: false, service_running: false, windows: null}
[log] [plugin] there are 0 windows already started
D/FloatwingService( 9657): [service] wait for service created
I/flutter ( 9657): start the backgroud service success.
I/FloatwingService( 9657): [service] create a window: test2 {entry=main, route=/normal}
D/FloatwingService( 9657): [service] wait for service created
[log] [event] register listener window.created for Window[test2]@834626997, EventManager@193599441, config: {"entry":"main","route":"/normal"}

What am I doing wrong? The permission is added in the AndroidManifest and granted in the initState dialog.

I'm using Flutter 3.0 and created a new project.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.