简体   繁体   English

在 flutter windows 桌面更改标题栏颜色

[英]Change title bar color in flutter windows desktop

I am developing a windows desktop application and would like to change the title bar color if possible.我正在开发一个 windows 桌面应用程序,如果可能的话,我想更改标题栏颜色。 for example I would like to go from something like this:例如我想 go 从这样的事情: 在此处输入图像描述

to something like this:像这样: 在此处输入图像描述

Is it possible using flutter and how to do it?是否可以使用 flutter 以及如何使用? Thanks.谢谢。

for this kind of customization, you will need to use the bitsdojo_windows community package, that allows you to customize the appearance of the window对于这种自定义,您需要使用bitsdojo_windows社区 package,它允许您自定义 window 的外观

A bit late to the party but you can use window_manager to achieve what you want.派对有点晚了,但你可以使用window_manager来实现你想要的。 In order to hide the title bar, you should use setTitleBarStyle() method before your runApp call, so the user will not see a lag or delay in UI.为了隐藏标题栏,您应该在调用runApp之前使用setTitleBarStyle()方法,这样用户就不会在 UI 中看到滞后或延迟。 Here's a minimal example:这是一个最小的例子:

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

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized(); //Must be called
  await windowManager.ensureInitialized(); //Must be called
  //waitUntilReadyToShow ==> Optional method to use, requires modification of native runner - Read docs of the package.
  await windowManager.waitUntilReadyToShow().then((_) async {
    await windowManager.setTitleBarStyle(TitleBarStyle.hidden); //Hiding the titlebar
    await windowManager.setTitle("I don't have a titlebar!"); //We don't have a titlebar, this title appears in Task Manager for example.
    await windowManager.show(); //Finally show app window.
  });
  runApp(const MyApp());
}


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

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: Scaffold(
        body: Center(
          child: Text('My Titlebar-less app!'),
        ),
      ),
    );
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM