Add window setup to provider_counter (#1046)

pull/1052/head
Miguel Beltran 3 years ago committed by GitHub
parent 25dcadb0ef
commit 9e9f1dea4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -2,10 +2,15 @@
// 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/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:window_size/window_size.dart';
void main() { void main() {
setupWindow();
runApp( runApp(
// Provide the model to all widgets within the app. We're using // Provide the model to all widgets within the app. We're using
// ChangeNotifierProvider because that's a simple way to rebuild // ChangeNotifierProvider because that's a simple way to rebuild
@ -23,6 +28,25 @@ void main() {
); );
} }
const double windowWidth = 360;
const double windowHeight = 640;
void setupWindow() {
if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) {
WidgetsFlutterBinding.ensureInitialized();
setWindowTitle('Provider Counter');
setWindowMinSize(const Size(windowWidth, windowHeight));
setWindowMaxSize(const Size(windowWidth, windowHeight));
getCurrentScreen().then((screen) {
setWindowFrame(Rect.fromCenter(
center: screen!.frame.center,
width: windowWidth,
height: windowHeight,
));
});
}
}
/// Simplest possible model, with just one field. /// Simplest possible model, with just one field.
/// ///
/// [ChangeNotifier] is a class in `flutter:foundation`. [Counter] does /// [ChangeNotifier] is a class in `flutter:foundation`. [Counter] does

@ -88,6 +88,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:
@ -162,7 +169,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:
@ -177,6 +184,15 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.1" version: "2.1.1"
window_size:
dependency: "direct main"
description:
path: "plugins/window_size"
ref: "03d957e8b5c99fc83cd4a781031b154ab3de8753"
resolved-ref: "03d957e8b5c99fc83cd4a781031b154ab3de8753"
url: "https://github.com/google/flutter-desktop-embedding.git"
source: git
version: "0.1.0"
sdks: sdks:
dart: ">=2.14.0 <3.0.0" dart: ">=2.14.0 <3.0.0"
flutter: ">=1.16.0" flutter: ">=1.16.0"

@ -1,6 +1,7 @@
name: provider_counter name: provider_counter
description: > description: >
The starter Flutter application, but using Provider to manage state. The starter Flutter application, but using Provider to manage state.
publish_to: none
version: 1.0.0 version: 1.0.0
@ -13,6 +14,11 @@ dependencies:
provider: ^5.0.0 provider: ^5.0.0
cupertino_icons: ^1.0.3 cupertino_icons: ^1.0.3
window_size:
git:
url: https://github.com/google/flutter-desktop-embedding.git
path: plugins/window_size
ref: 03d957e8b5c99fc83cd4a781031b154ab3de8753
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:

Loading…
Cancel
Save