mirror of
https://github.com/flutter/samples.git
synced 2025-11-08 13:58:47 +00:00
Add desktop window setup to infinite_list (#1040)
This commit is contained in:
@@ -2,16 +2,40 @@
|
||||
// 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:provider/provider.dart';
|
||||
import 'package:window_size/window_size.dart';
|
||||
|
||||
import 'src/catalog.dart';
|
||||
import 'src/item_tile.dart';
|
||||
|
||||
void main() {
|
||||
setupWindow();
|
||||
runApp(const MyApp());
|
||||
}
|
||||
|
||||
const double kWindowWidth = 480;
|
||||
const double kWindowHeight = 854;
|
||||
|
||||
void setupWindow() {
|
||||
if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
setWindowTitle('Infinite List');
|
||||
setWindowMinSize(const Size(kWindowWidth, kWindowHeight));
|
||||
setWindowMaxSize(const Size(kWindowWidth, kWindowHeight));
|
||||
getCurrentScreen().then((screen) {
|
||||
setWindowFrame(Rect.fromCenter(
|
||||
center: screen!.frame.center,
|
||||
width: kWindowWidth,
|
||||
height: kWindowHeight,
|
||||
));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({Key? key}) : super(key: key);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user