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:
@@ -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,
|
||||
));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user