mirror of
https://github.com/flutter/samples.git
synced 2025-11-08 13:58:47 +00:00
Add window setup to veggie seasons (#1049)
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -163,6 +163,13 @@ packages:
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
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:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -342,7 +349,7 @@ packages:
|
||||
name: test_api
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.4.3"
|
||||
version: "0.4.8"
|
||||
typed_data:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -364,6 +371,15 @@ packages:
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
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:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
name: veggieseasons
|
||||
description: An iOS app that shows the fruits and veggies currently in season.
|
||||
publish_to: none
|
||||
|
||||
version: 1.2.0
|
||||
|
||||
@@ -15,6 +16,10 @@ dependencies:
|
||||
intl: ^0.17.0
|
||||
provider: ^6.0.1
|
||||
shared_preferences: ^2.0.5
|
||||
window_size:
|
||||
git:
|
||||
url: https://github.com/google/flutter-desktop-embedding
|
||||
path: plugins/window_size
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
||||
Reference in New Issue
Block a user