mirror of
https://github.com/chenasraf/mudblock.git
synced 2026-05-18 01:48:57 +00:00
70 lines
1.8 KiB
Dart
70 lines
1.8 KiB
Dart
import 'dart:io';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:window_manager/window_manager.dart';
|
|
|
|
import 'core/platform_utils.dart';
|
|
import 'core/routes.dart';
|
|
import 'core/storage.dart';
|
|
import 'core/storage/shared_prefs.dart';
|
|
import 'core/store.dart';
|
|
|
|
void main() async {
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
await getPrefs();
|
|
await FileStorage.init();
|
|
await gameStore.init();
|
|
if (PlatformUtils.isDesktop) {
|
|
await windowManager.ensureInitialized();
|
|
|
|
final w = prefs.getInt('windowWidth') ?? 1000;
|
|
final h = prefs.getInt('windowHeight') ?? 900;
|
|
final size = Size(w.toDouble(), h.toDouble());
|
|
|
|
WindowOptions windowOptions = WindowOptions(
|
|
size: size,
|
|
backgroundColor: Colors.transparent,
|
|
skipTaskbar: false,
|
|
titleBarStyle: TitleBarStyle.hidden,
|
|
);
|
|
windowManager.waitUntilReadyToShow(windowOptions, () async {
|
|
await windowManager.show();
|
|
await windowManager.focus();
|
|
});
|
|
}
|
|
runApp(const MyApp());
|
|
}
|
|
|
|
class MyApp extends StatelessWidget {
|
|
const MyApp({super.key});
|
|
|
|
// This widget is the root of your application.
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final theme = ThemeData(
|
|
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
|
|
useMaterial3: true,
|
|
);
|
|
return MaterialApp(
|
|
title: 'Mudblock',
|
|
theme: theme,
|
|
builder: (context, child) {
|
|
return GameStore.provider(
|
|
child: Container(
|
|
color: theme.colorScheme.background,
|
|
child: Padding(
|
|
padding: PlatformUtils.isDesktop
|
|
? EdgeInsets.only(top: Platform.isMacOS ? 28.0 : 32.0)
|
|
: EdgeInsets.zero,
|
|
child: child!,
|
|
),
|
|
),
|
|
);
|
|
},
|
|
initialRoute: Paths.home,
|
|
routes: routes,
|
|
);
|
|
}
|
|
}
|
|
|