Flutter desktop - change window title from Dart code
2,753
Solution 1
It is possible, as mentioned in https://github.com/flutter/flutter/issues/30712
In pubspec.yaml
add
dependencies:
window_size:
git:
url: git://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';
setWindowTitle("Custom window title");
Works fine on Linux. Haven't tested on Windows/Mac
Solution 2
Go to windows > runner > main.cpp folder, find a " !window.CreateAndShow(L"schedule_task", origin, size) " And change the "schedule_task" text
Solution 3
Ok, that seems to be not possible (yet), but work in progress: https://github.com/flutter/flutter/issues/30712
Author by
user1209216
Updated on December 21, 2022Comments
-
user1209216 over 1 year
I am unable to find any way to do that when searching official documentation. Does anybody know any way to do that?
-
Grady Werner almost 3 yearsWhile 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
-
Promlert Lovichit over 2 yearsThai text was displayed incorrectly. :(
-
Johan Ordenes Galleguillos about 2 yearsCan't edit answer, but make sure to add WidgetsFlutterBinding.ensureInitialized(); before setWindowsTitle("").