Add window setup to veggie seasons (#1049)

pull/1052/head
Miguel Beltran 3 years ago committed by GitHub
parent 35713ac2d9
commit 03dbbcd667
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -2,13 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:io';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart' show DeviceOrientation, SystemChrome; import 'package:flutter/services.dart' show DeviceOrientation, SystemChrome;
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:veggieseasons/data/app_state.dart'; import 'package:veggieseasons/data/app_state.dart';
import 'package:veggieseasons/data/preferences.dart'; import 'package:veggieseasons/data/preferences.dart';
import 'package:veggieseasons/screens/home.dart'; import 'package:veggieseasons/screens/home.dart';
import 'package:veggieseasons/styles.dart'; import 'package:veggieseasons/styles.dart';
import 'package:window_size/window_size.dart';
void main() { void main() {
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
@ -16,6 +20,7 @@ void main() {
DeviceOrientation.portraitUp, DeviceOrientation.portraitUp,
DeviceOrientation.portraitDown, DeviceOrientation.portraitDown,
]); ]);
setupWindow();
runApp( runApp(
const RootRestorationScope( 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 { class VeggieApp extends StatefulWidget {
const VeggieApp({Key? key}) : super(key: key); const VeggieApp({Key? key}) : super(key: key);

@ -163,6 +163,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.12.11" version: "0.12.11"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.3"
meta: meta:
dependency: transitive dependency: transitive
description: description:
@ -342,7 +349,7 @@ packages:
name: test_api name: test_api
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.4.3" version: "0.4.8"
typed_data: typed_data:
dependency: transitive dependency: transitive
description: description:
@ -364,6 +371,15 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.3.3" version: "2.3.3"
window_size:
dependency: "direct main"
description:
path: "plugins/window_size"
ref: HEAD
resolved-ref: "5c51870ced62a00e809ba4b81a846a052d241c9f"
url: "https://github.com/google/flutter-desktop-embedding"
source: git
version: "0.1.0"
xdg_directories: xdg_directories:
dependency: transitive dependency: transitive
description: description:

@ -1,5 +1,6 @@
name: veggieseasons name: veggieseasons
description: An iOS app that shows the fruits and veggies currently in season. description: An iOS app that shows the fruits and veggies currently in season.
publish_to: none
version: 1.2.0 version: 1.2.0
@ -15,6 +16,10 @@ dependencies:
intl: ^0.17.0 intl: ^0.17.0
provider: ^6.0.1 provider: ^6.0.1
shared_preferences: ^2.0.5 shared_preferences: ^2.0.5
window_size:
git:
url: https://github.com/google/flutter-desktop-embedding
path: plugins/window_size
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:

Loading…
Cancel
Save