Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot start Window with entry-point #17

Open
mulaRahul opened this issue Dec 30, 2022 · 2 comments
Open

Cannot start Window with entry-point #17

mulaRahul opened this issue Dec 30, 2022 · 2 comments

Comments

@mulaRahul
Copy link

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");
  }
}
@peyman-se
Copy link

This is my issue as well when using routes

@jiusanzhou
Copy link
Owner

Hi thank you for your guys attention to this package, I will look into it in few days later

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants