When using Windows_Manager and UI to make the app take the entire screen, I get the following error:
Invalid constant value.
Here is the code:
import 'dart:ui' as ui;
import 'package:window_manager/window_manager.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
Size logicalScreenSize = ui.window.physicalSize;
WindowOptions windowOptions = const WindowOptions(
size: logicalScreenSize, //Error in this instruction
center: true,
backgroundColor: Colors.transparent,
skipTaskbar: false,
titleBarStyle: TitleBarStyle.hidden,
);
windowManager.waitUntilReadyToShow(windowOptions, () async {
await windowManager.show();
await windowManager.focus();
});
await SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
DeviceOrientation.portraitDown,
]);
runApp(const MyApp());
}
I tried to combine most of the proposed solutions here but non of them works.
EDIT
The previous error has been resolved, but the app is still not taking the size of the screen!!
2
Answers
So, the issue is, the
logicalScreenSize
variable is not constant means the the value will not be same that’s why you can’t assign that to const.As I can you’ve did this
Now you just need to delete const from first line
I removed const from
WindowOptions
SIZE NOT WORKING
You need to assign
minimumSize
as wellRemove this
const
and try and run