31.19 Flutter Desktop App Window Title


To set the window title for a desktop application through the Window Manager see Section 31.18. Here we present an older alternative to set the default window title using the window_size pacakge which is not part of pud.dev but can be obtained from github.

Add the following to pubspec.yaml:

      url: https://github.com/google/flutter-desktop-embedding.git
      path: plugins/window_size
      ref: 6c66ad23ee79749f30a8eece542cf54eaf157ed8

The ref: is the github SHA hash key of the commit to use. Choose the latest one at the time of implementing. It can be dropped but is useful to avoid code suddenly failing.

Then in lib/main.dart import the required libraries (foundation.dart is required for the Platform checks) and add the conditional statement with setWindowTitle(). We do this in main() so that it is set before the app runs to ensure the app does not stutter with the original window title in starting up.

import 'package:flutter/foundation.dart';

import 'package:window_size/window_size.dart';

void main() {

  // Identify if Desktop or Mobile app.

  desktop = [TargetPlatform.linux, TargetPlatform.macOS, TargetPlatform.windows];
  bool isDesktop = defaultTargetPlatform in desktop;

  // Tune the window manager before runApp to avoid a lag in the UI.

  if (isDesktop) {



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

  Widget build(BuildContext context) {
    return MaterialApp(

Your donation will support ongoing availability and give you access to the PDF version of this book. Desktop Survival Guides include Data Science, GNU/Linux, and MLHub. Books available on Amazon include Data Mining with Rattle and Essentials of Data Science. Popular open source software includes rattle, wajig, and mlhub. Hosted by Togaware, a pioneer of free and open source software since 1984. Copyright © 1995-2022 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0