window_manager_plus 1.0.5 copy "window_manager_plus: ^1.0.5" to clipboard
window_manager_plus: ^1.0.5 copied to clipboard

This plugin allows Flutter desktop apps to create and manage multiple windows, such as resizing and repositioning, and communicate between them.

example/lib/main.dart

import 'package:bot_toast/bot_toast.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:window_manager_plus/window_manager_plus.dart';
import 'package:window_manager_plus_example/pages/home.dart';
import 'package:window_manager_plus_example/utils/config.dart';

void main(List<String> args) async {
  if (kDebugMode) {
    print(args);
  }

  WidgetsFlutterBinding.ensureInitialized();
  await WindowManagerPlus.ensureInitialized(args.isEmpty ? 0 : int.tryParse(args[0]) ?? 0);

  WindowOptions windowOptions = const WindowOptions(
    size: Size(800, 600),
    center: true,
    backgroundColor: Colors.transparent,
    skipTaskbar: false,
    titleBarStyle: TitleBarStyle.hidden,
    windowButtonVisibility: false,
  );
  WindowManagerPlus.current.waitUntilReadyToShow(windowOptions, () async {
    await WindowManagerPlus.current.show();
    await WindowManagerPlus.current.focus();

    if (WindowManagerPlus.current.id != 0) {
      WindowManagerPlus.current.invokeMethodToWindow(0, 'testMethod').then((value) {
        BotToast.showText(text: 'Response from 0: $value');
      },);
    }
  });

  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  ThemeMode _themeMode = ThemeMode.light;

  @override
  void initState() {
    sharedConfigManager.addListener(_configListen);
    super.initState();
  }

  @override
  void dispose() {
    sharedConfigManager.removeListener(_configListen);
    super.dispose();
  }

  void _configListen() {
    _themeMode = sharedConfig.themeMode;
    setState(() {});
  }

  @override
  Widget build(BuildContext context) {
    final virtualWindowFrameBuilder = VirtualWindowFrameInit();
    final botToastBuilder = BotToastInit();

    return MaterialApp(
      debugShowCheckedModeBanner: false,
      themeMode: _themeMode,
      builder: (context, child) {
        child = virtualWindowFrameBuilder(context, child);
        child = botToastBuilder(context, child);
        return child;
      },
      navigatorObservers: [BotToastNavigatorObserver()],
      home: const HomePage(),
    );
  }
}
17
likes
160
pub points
78%
popularity

Publisher

unverified uploader

This plugin allows Flutter desktop apps to create and manage multiple windows, such as resizing and repositioning, and communicate between them.

Repository (GitHub)
View/report issues

Topics

#window #window-resize #window-manager #multi-window #desktop

Documentation

API reference

Funding

Consider supporting this project:

www.paypal.com

License

MIT (license)

Dependencies

flutter, path, screen_retriever

More

Packages that depend on window_manager_plus