Change title bar color in flutter windows desktop
Asked Answered
I

3

5

I am developing a windows desktop application and would like to change the title bar color if possible. for example I would like to go from something like this: enter image description here

to something like this: enter image description here

Is it possible using flutter and how to do it? Thanks.

Inoffensive answered 25/6, 2021 at 11:55 Comment(0)
S
3

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

Stylolite answered 25/6, 2021 at 12:5 Comment(1)
That library is very buggy and crashy fyi.Luxor
A
3

A bit late to the party but you can use window_manager to achieve what you want. 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. 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!'),
        ),
      ),
    );
  }
}

Augite answered 25/11, 2022 at 22:15 Comment(4)
not working at alllWardrobe
@NicholasJela Please let me know "how" it's not working. I will be happy to explain further and edit the answer if needed.Augite
Title is not displaying due to color IssueMoeller
github.com/foamify/rounded_corner_example/blob/main/lib/… For anyone in the future take a look at this github repositoryGemperle
A
0

you can use window_manager

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

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await windowManager.ensureInitialized();

  WindowOptions windowOptions = const WindowOptions(
    size: Size(800, 600),
    center: true,
    backgroundColor: Colors.transparent,
    skipTaskbar: false,
    titleBarStyle: TitleBarStyle.hidden,
  );
  windowManager.waitUntilReadyToShow(windowOptions, () async {
    await windowManager.focus();
  });
  runApp(
    MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        appBar: PreferredSize(
          preferredSize: const Size(double.maxFinite, 50),
          child: DragToMoveArea(
            child: AppBar(
              backgroundColor: Colors.green,
              actions: [
                IconButton(
                  onPressed: () => windowManager.minimize(),
                  icon: const Icon(Icons.minimize),
                ),
                IconButton(
                  onPressed: () => windowManager.maximize(),
                  icon: const Icon(Icons.maximize),
                ),
                IconButton(
                  onPressed: () => windowManager.close(),
                  icon: const Icon(Icons.close),
                ),
              ],
            ),
          ),
        ),
      ),
    ),
  );
}
Animatism answered 10/7 at 16:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.