1
0
mirror of https://github.com/flutter/samples.git synced 2025-11-08 13:58:47 +00:00

Add window desktop setup to navigation_and_routing (#1043)

This commit is contained in:
Miguel Beltran
2022-03-08 02:04:47 +01:00
committed by GitHub
parent 9e9f1dea4c
commit c452c1fcce
3 changed files with 48 additions and 10 deletions

View File

@@ -2,8 +2,12 @@
// for details. All rights reserved. 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/foundation.dart';
import 'package:flutter/material.dart';
import 'package:url_strategy/url_strategy.dart';
import 'package:window_size/window_size.dart';
import 'src/app.dart';
@@ -19,5 +23,25 @@ void main() {
setHashUrlStrategy();
// setPathUrlStrategy();
setupWindow();
runApp(const Bookstore());
}
const double windowWidth = 480;
const double windowHeight = 854;
void setupWindow() {
if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) {
WidgetsFlutterBinding.ensureInitialized();
setWindowTitle('Navigation and routing');
setWindowMinSize(const Size(windowWidth, windowHeight));
setWindowMaxSize(const Size(windowWidth, windowHeight));
getCurrentScreen().then((screen) {
setWindowFrame(Rect.fromCenter(
center: screen!.frame.center,
width: windowWidth,
height: windowHeight,
));
});
}
}