GithubHelp home page GithubHelp logo

无法获取window about flutter_floatwing HOT 2 CLOSED

LondonX avatar LondonX commented on May 31, 2024
无法获取window

from flutter_floatwing.

Comments (2)

jiusanzhou avatar jiusanzhou commented on May 31, 2024

Hi, 你可能需要一些初始化才能获取window对象。

In your window engine, you can access the window object in 2 ways:

Directly access the cache field of plugin: FloatwingPlugin().currentWindow.
If widget injected by .floatwing(), you can take window with Window.of(context).

可以提供一下你的window的代码吗?

from flutter_floatwing.

LondonX avatar LondonX commented on May 31, 2024

获取对象相关代码已删除,目前解决方案是通过Android广播机制来传值。

初始化悬浮窗(main.dart中)

@pragma("vm:entry-point")
void overlayPlayer() {
  runApp(const OverlayApp(
    child: OverlayPlayerView(),
  ));
}
@pragma("vm:entry-point")
void overlayDestroyer() {
  runApp(const OverlayApp(
    child: OverlayDestroyer(),
  ));
}

显示悬浮窗

await WindowConfig(
      entry: "overlayPlayer",
      draggable: true,
      clickable: true,
      focusable: false,
      height: (_playerSize * _pxRatio).round(),
      width: (_playerSize * _pxRatio).round(),
      id: "overlayPlayer",
      x: (_screenSize.width - _playerSize * _pxRatio).round(),
      y: (_screenSize.height / 2 + 100).round(),
      immersion: true,
    ).to().create(start: true)
await WindowConfig(
      entry: "overlayDestroyer",
      draggable: false,
      clickable: false,
      focusable: false,
      height: (100 * _pxRatio).round(),
      width: (_screenSize.width).round(),
      y: (_screenSize.height - 100 * _pxRatio).round(),
      id: "overlayDestroyer",
      immersion: true,
    ).to().create(start: true);

from flutter_floatwing.

Related Issues (20)

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.