1
0
mirror of https://github.com/flutter/samples.git synced 2026-05-03 13:26:06 +00:00

Add window setup to veggie seasons (#1049)

This commit is contained in:
Miguel Beltran
2022-03-09 08:04:46 +01:00
committed by GitHub
parent 35713ac2d9
commit 03dbbcd667
3 changed files with 45 additions and 1 deletions

View File

@@ -2,13 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:io';
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart' show DeviceOrientation, SystemChrome;
import 'package:provider/provider.dart';
import 'package:veggieseasons/data/app_state.dart';
import 'package:veggieseasons/data/preferences.dart';
import 'package:veggieseasons/screens/home.dart';
import 'package:veggieseasons/styles.dart';
import 'package:window_size/window_size.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
@@ -16,6 +20,7 @@ void main() {
DeviceOrientation.portraitUp,
DeviceOrientation.portraitDown,
]);
setupWindow();
runApp(
const RootRestorationScope(
@@ -25,6 +30,24 @@ void main() {
);
}
const double windowWidth = 480;
const double windowHeight = 854;
void setupWindow() {
if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) {
setWindowTitle('Veggie Seasons');
setWindowMinSize(const Size(windowWidth, windowHeight));
setWindowMaxSize(const Size(windowWidth, windowHeight));
getCurrentScreen().then((screen) {
setWindowFrame(Rect.fromCenter(
center: screen!.frame.center,
width: windowWidth,
height: windowHeight,
));
});
}
}
class VeggieApp extends StatefulWidget {
const VeggieApp({Key? key}) : super(key: key);