bitsdojo / bitsdojo_window

A Flutter package that makes it easy to customize and work with your Flutter desktop app window.
http://www.youtube.com/watch?v=bee2AHQpGK4
MIT License
815 stars 229 forks source link

App crashes when trying to resize window on Linux #194

Open khanliKU opened 2 years ago

khanliKU commented 2 years ago

I created an app that works on Windows using bitsdojo_window + fluent_ui. I want to port this app to Linux and MacOS.

When I try to navigate to a new page the app is not stable. It stops responding: image

Sample program

import 'package:fluent_ui/fluent_ui.dart';
import 'package:bitsdojo_window/bitsdojo_window.dart';

void main() {
  runApp(FluentApp(
    title: 'Flutter Demo',
    debugShowCheckedModeBanner: false,
    initialRoute: '/',
    routes: {'/': (_) => const DesktopHomePage ()}
    ),
  );
  doWhenWindowReady(() {
    appWindow.alignment = Alignment.center;
    appWindow.show();
  });
}

class DesktopHomePage extends StatefulWidget {
  const DesktopHomePage({Key? key}) : super(key: key);
  @override
  State<DesktopHomePage> createState() => _DesktopHomePageState ();
}

class _DesktopHomePageState extends State<DesktopHomePage> {
  @override
  void initState() {
    const initialSize = Size(640, 360);
    appWindow.minSize = initialSize;
    appWindow.maxSize = initialSize;
    appWindow.size = initialSize;
    super.initState();
  }
  @override
  Widget build(BuildContext context) {
    return Center(
      child: Button(
        child: const Text('Transition'),
        onPressed: () {
          Navigator.push(
            context,
            FluentPageRoute(builder: (context) => const NextPage()),
          );
        },
      ),
    );
  }
}

class NextPage extends StatefulWidget {
  const NextPage({Key? key}) : super(key: key);
  @override
  State<NextPage> createState() => _NextPageState ();
}

class _NextPageState extends State<NextPage> {
  @override
  void initState() {
    const initialSize = Size(1080, 720);
    appWindow.minSize = initialSize;
    appWindow.maxSize = initialSize;
    appWindow.size = initialSize;
    super.initState();
  }
  @override
  Widget build(BuildContext context) {
    return Center(
     child: const Text('Next Page'),
    );
  }
}
khanliKU commented 2 years ago

pubspec.yaml:

Windows theme

fluent_ui: ^3.12.0 system_theme: ^2.0.0 flutter_acrylic: ^1.0.0+2 bitsdojo_window: '>=0.1.2 <0.1.3'