20

I am unable to find any way to do that when searching official documentation. Does anybody know any way to do that?

5 Answers 5

24

It is possible, as mentioned in https://github.com/flutter/flutter/issues/30712

In pubspec.yaml add

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

Now in your code just call

import 'package:window_size/window_size.dart'; WidgetsFlutterBinding.ensureInitialized(); setWindowTitle("Custom window title"); 

Works fine on Linux. Haven't tested on Windows/Mac

PS Thanks to @Johan Ordenes Galleguillos for the missing WidgetsFlutterBinding.ensureInitialized();

Sign up to request clarification or add additional context in comments.

4 Comments

Can't edit answer, but make sure to add WidgetsFlutterBinding.ensureInitialized(); before setWindowsTitle("").
It also worked on Mac.
I had to use the url https://github.com/google/flutter-desktop-embedding.git to get this to work, which is what the referenced issue above used. The url in this answer on the other hand gave me pub get failed (server unavailable) and infinite retries.
When I run this, the debugger pauses at setWindowTitle(...). I inserted the lines inside the MainPage.build(...) function when I run as Chrome executable. Any ideas?
7

Go to windows > runner > main.cpp folder, find a " !window.CreateAndShow(L"schedule_task", origin, size) " And change the "schedule_task" text

2 Comments

While this does work, it removes the ability to use localization functions to have different text for different locales. If you need that functionality, it's probably better to use the solution from @tomrozb
Thai text was displayed incorrectly. :(
5

Achieved this by using windowmanager package. It has a lot of features for desktop development with flutter.

After installing package just add this to main():

void main() async { //needed to ensure binding was initialized WidgetsFlutterBinding.ensureInitialized(); await WindowManager.instance.ensureInitialized(); windowManager.waitUntilReadyToShow().then((_) async { await windowManager.setTitle('Yor title goes here'); }); runApp(const MyApp()); } 

for me worked with Windows and Linux.

references:

WidgetsFlutterBinding class

window manager Documentation

2 Comments

actually you don't need windowManager.waitUntilReadyToShow().then((_) {} scope for this, but if you plan, for example, resize your window its's better to have it.
That works but it also moves the window. Any idea why that is or how to prevent it?
1

Ok, that seems to be not possible (yet), but work in progress: https://github.com/flutter/flutter/issues/30712

Comments

0

In order to replace flutter app title on the Windows caption bar, as well as optionally adjusting the dimensions for size and the window coordinates you have to navigate to windows/main.cpp file and edit following code: !window.Create(L"My App New Title Here", origin, size) Source: https://docs.flutter.dev/platform-integration/windows/building

2 Comments

That way you can set default size and title, you can't change title dynamically while app is running
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From Review

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.