MixinNetwork / MixinNetwork/flutter-plugins

When a new window opens on MacOS, it appears after a short black screen

Open
#321 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
512
Forks
292
Avg merge
15h 8m
Merged PRs (30d)
7

Description

When opening a new window on MacOS, there is a short black screen, I don't know if this is a MacOS problem.

https://github.com/MixinNetwork/flutter-plugins/assets/18432861/d9948e93-867a-4d9e-956c-e4c5eebb88c8

 import 'dart:convert';

import 'package:collection/collection.dart';
import 'package:desktop_multi_window/desktop_multi_window.dart';
import 'package:flutter/material.dart';
import 'package:window_manager/window_manager.dart';

void main(List<String> args) async {
  WidgetsFlutterBinding.ensureInitialized();

  if (args.firstOrNull == 'multi_window') {
    runApp(const MySubWindow());
  } else {
    // WidgetsFlutterBinding.ensureInitialized();

    await windowManager.ensureInitialized();

    windowManager.waitUntilReadyToShow().then((_) async {
      await windowManager.setTitle('flutter desktop_multi_window demo');
      await windowManager.setSize(const Size(800, 600));
      await windowManager.setMinimumSize(const Size(800, 600));
      await windowManager.center();
      await windowManager.show();
      // await windowManager.setSkipTaskbar(false);
    });

    runApp(const MaterialApp(home: MultiWindowPage()));
  }
}

class MultiWindowPage extends StatefulWidget {
  const MultiWindowPage({Key? key}) : super(key: key);

  @override
  State<MultiWindowPage> createState() => _MultiWindowPageState();
}

class _MultiWindowPageState extends State<MultiWindowPage> {
  void _addWindow() async {
    final window = await DesktopMultiWindow.createWindow(jsonEncode({}));
    window
      ..setFrame(const Offset(0, 0) & const Size(600, 450))
      ..center()
      ..setTitle('标题')
      ..show();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            ElevatedButton(
              onPressed: _addWindow,
              child: const Text('打开子窗口'),
            ),
          ],
        ),
      ),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        primarySwatch: Colors.blue,
        fontFamily: 'Microsoft YaHei',
      ),
      home: const Scaffold(
        body: Center(
          child: Text(
            '这里是新的窗口',
            style: TextStyle(fontSize: 24),
          ),
        ),
      ),
    );
  }
}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the black screen on macOS using the sample entry points _addWindow, MySubWindow, and the windowManager.waitUntilReadyToShow sequence shown in the issue. Compare the timing of window creation, showing, and Flutter content initialization; done means a new window opens without the visible black interval.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart, flutter, macos
Domain
desktop
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.