123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- 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',
- ),
- home: IndexPage(),
- );
- }
- );
- }
- }
|