Skip to content

Commit a094715

Browse files
authored
fix: windows title bar theme switch (#936)
1 parent 69bb875 commit a094715

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

ui/flutter/lib/app/modules/app/views/app_view.dart

+15
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ import 'package:flutter/material.dart';
22
import 'package:flutter_foreground_task/flutter_foreground_task.dart';
33
import 'package:flutter_localizations/flutter_localizations.dart';
44
import 'package:get/get.dart';
5+
import 'package:window_manager/window_manager.dart'; // Import the required packages
56

67
import '../../../../i18n/message.dart';
78
import '../../../../theme/theme.dart';
89
import '../../../../util/locale_manager.dart';
10+
import '../../../../util/util.dart'; // Import the required packages
911
import '../../../routes/app_pages.dart';
1012
import '../controllers/app_controller.dart';
1113

@@ -32,6 +34,19 @@ class AppView extends GetView<AppController> {
3234
],
3335
supportedLocales: messages.keys.keys.map((e) => toLocale(e)).toList(),
3436
getPages: AppPages.routes,
37+
38+
// Add listening to theme changes, set the title bar color according to the current system theme.
39+
builder: (context, child) {
40+
// if platform is desktop
41+
if (Util.isDesktop()){
42+
// actual brightness of the UI
43+
Brightness brightness = Theme.of(context).brightness;
44+
// Set the title bar to use the actual brightness of the UI
45+
windowManager.setBrightness(brightness);
46+
}
47+
return child!;
48+
},
49+
3550
),
3651
);
3752
}

0 commit comments

Comments
 (0)