12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- import 'dart:io';
- import 'package:flutter/material.dart';
- import 'package:flutter/services.dart';
- import 'package:flutter_clock/index_page.dart';
- import 'package:flutter_clock/utils/app_utils.dart';
- import 'package:flutter_screenutil/flutter_screenutil.dart';
- import 'package:window_manager/window_manager.dart';
- /// Description: enter point of the app
- /// Time : 04/06/2025 Sunday
- /// Author : liuyuqi.gov@msn.cn
- void main() async {
- WidgetsFlutterBinding.ensureInitialized();
- AppUtils.setOverrideForDesktop();
-
- // Initialize window manager for desktop platforms
- if (Platform.isWindows || Platform.isLinux || Platform.isMacOS) {
- await windowManager.ensureInitialized();
-
- // Calculate window size with 16:9 portrait ratio
- // Common phone resolution is 1080x1920 (16:9 portrait)
- const double width = 360.0; // Phone width
- const double height = 640.0; // Phone height (16:9 ratio)
-
- WindowOptions windowOptions = WindowOptions(
- size: Size(width, height),
- center: true,
- backgroundColor: Colors.transparent,
- skipTaskbar: false,
- titleBarStyle: TitleBarStyle.normal,
- );
-
- await windowManager.waitUntilReadyToShow(windowOptions, () async {
- await windowManager.show();
- await windowManager.focus();
- });
- }
-
- // Configure system settings for better background execution
- if (Platform.isAndroid) {
- SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
- statusBarColor: Colors.transparent,
- statusBarIconBrightness: Brightness.dark,
- ));
-
- // Prevent app from being killed in background
- SystemChannels.platform.invokeMethod('SystemChrome.setEnabledSystemUIMode', [
- SystemUiMode.edgeToEdge.index,
- ]);
- }
-
- runApp(MyApp());
- }
- class MyApp extends StatelessWidget {
- @override
- Widget build(BuildContext context) {
- // Initialize ScreenUtil for responsive UI
- return ScreenUtilInit(
- designSize: const Size(360, 640), // Base design size
- minTextAdapt: true,
- splitScreenMode: true,
- builder: (context, child) {
- return MaterialApp(
- title: 'Flutter Clock',
- debugShowCheckedModeBanner: false,
- theme: ThemeData(
- primarySwatch: Colors.blue,
- visualDensity: VisualDensity.adaptivePlatformDensity,
- fontFamily: 'Roboto',
- brightness: Brightness.light,
- tabBarTheme: TabBarTheme(
- labelColor: Colors.blue,
- unselectedLabelColor: Colors.black87,
- indicatorSize: TabBarIndicatorSize.tab,
- labelStyle: TextStyle(fontWeight: FontWeight.bold),
- unselectedLabelStyle: TextStyle(fontWeight: FontWeight.normal),
- ),
- appBarTheme: AppBarTheme(
- color: Colors.white,
- foregroundColor: Colors.black,
- elevation: 1.0,
- ),
- ),
- home: IndexPage(),
- );
- }
- );
- }
- }
|