Complete refactor to clean up project

This commit is contained in:
2026-02-04 11:36:02 +01:00
parent 4f380b5444
commit 704bd0b928
29 changed files with 2057 additions and 1464 deletions

View File

@@ -1,49 +1,47 @@
import 'dart:io';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_fullscreen/flutter_fullscreen.dart';
import 'package:hive/hive.dart';
import 'package:logging/logging.dart';
import 'package:path_provider/path_provider.dart';
import 'package:pdfrx/pdfrx.dart';
import 'package:flutter_fullscreen/flutter_fullscreen.dart';
import 'login_page.dart';
import 'app.dart';
final RouteObserver<ModalRoute> routeObserver = RouteObserver<ModalRoute>();
/// Application entry point.
///
/// Performs platform-specific initialization before running the app
Future<void> main() async {
Logger.root.level = Level.ALL; // defaults to Level.INFO
WidgetsFlutterBinding.ensureInitialized();
await _initializeLogging();
await _initializePlugins();
runApp(const SheetlessApp());
}
/// Configures the logging system.
Future<void> _initializeLogging() async {
Logger.root.level = Level.ALL;
Logger.root.onRecord.listen((record) {
debugPrint('${record.level.name}: ${record.time}: ${record.message}');
if (record.error != null) {
debugPrint('${record.error}');
}
});
}
// setup for flutter_fullscreen
WidgetsFlutterBinding.ensureInitialized(); // Needs to be initialized first, otherwise app gets stuck in splash screen
/// Initializes platform-specific plugins and services.
Future<void> _initializePlugins() async {
// Fullscreen support
await FullScreen.ensureInitialized();
pdfrxFlutterInitialize(); // Needed especially for web
// PDF rendering (especially needed for web)
pdfrxFlutterInitialize();
// Local storage (not supported on web)
if (!kIsWeb) {
Directory dir = await getApplicationDocumentsDirectory();
Hive.init(dir.path); // Needed only if not web
}
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Sheetless',
theme: ThemeData(useMaterial3: true, primarySwatch: Colors.blue),
home: const LoginPage(),
navigatorObservers: [routeObserver],
);
final dir = await getApplicationDocumentsDirectory();
Hive.init(dir.path);
}
}