From b2daccca71db6efe9d28cd90aa9b294a0fb74b97 Mon Sep 17 00:00:00 2001 From: Miguel Beltran Date: Fri, 4 Mar 2022 00:01:53 +0100 Subject: [PATCH] Add desktop window setup to isolate_example (#1041) --- isolate_example/lib/main.dart | 16 ++++++++++++++++ isolate_example/pubspec.lock | 18 +++++++++++++++++- isolate_example/pubspec.yaml | 6 ++++++ 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/isolate_example/lib/main.dart b/isolate_example/lib/main.dart index e70e9d53b..e10c8c2d7 100644 --- a/isolate_example/lib/main.dart +++ b/isolate_example/lib/main.dart @@ -12,13 +12,18 @@ // See the License for the specific language governing permissions and // limitations under the License. +import 'dart:io'; + +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; +import 'package:window_size/window_size.dart'; import 'data_transfer_page.dart'; import 'infinite_process_page.dart'; import 'performance_page.dart'; void main() { + setupWindow(); runApp( const MaterialApp( home: HomePage(), @@ -26,6 +31,17 @@ void main() { ); } +const double kWindowWidth = 1024; +const double kWindowHeight = 800; + +void setupWindow() { + if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { + WidgetsFlutterBinding.ensureInitialized(); + setWindowTitle('Isolate Example'); + setWindowMinSize(const Size(kWindowWidth, kWindowHeight)); + } +} + class HomePage extends StatelessWidget { const HomePage({Key? key}) : super(key: key); diff --git a/isolate_example/pubspec.lock b/isolate_example/pubspec.lock index acdb236ff..8845d786b 100644 --- a/isolate_example/pubspec.lock +++ b/isolate_example/pubspec.lock @@ -81,6 +81,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: @@ -155,7 +162,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: @@ -170,6 +177,15 @@ packages: url: "https://pub.dartlang.org" source: hosted 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: dart: ">=2.14.0 <3.0.0" flutter: ">=1.16.0" diff --git a/isolate_example/pubspec.yaml b/isolate_example/pubspec.yaml index 08cf2cb82..e02fabba3 100644 --- a/isolate_example/pubspec.yaml +++ b/isolate_example/pubspec.yaml @@ -1,6 +1,7 @@ name: isolate_example description: A Flutter sample to demonstrate isolates version: 1.0.0+1 +publish_to: none environment: sdk: ">=2.12.0 <3.0.0" @@ -9,6 +10,11 @@ dependencies: flutter: sdk: flutter provider: ^5.0.0 + window_size: + git: + url: https://github.com/google/flutter-desktop-embedding.git + path: plugins/window_size + ref: 03d957e8b5c99fc83cd4a781031b154ab3de8753 dev_dependencies: flutter_test: