Initial commit

This commit is contained in:
2025-11-10 07:18:20 +01:00
commit 4a8774fa0a
208 changed files with 7586 additions and 0 deletions

View File

@@ -0,0 +1,54 @@
import 'dart:io';
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'package:window_manager/window_manager.dart';
/// A utility class for initializing the Flutter application.
///
/// This class ensures Flutter bindings are initialized, configures
/// window dimensions for desktop applications, and sets the device
/// orientation for mobile platforms.
class AppInitializer {
/// Initializes the application setup.
///
/// Ensures Flutter bindings are initialized, sets up window dimensions,
/// and configures device orientation settings.
static initialize() async {
_ensureInitialized();
await _setupWindowDimensions();
await _setupDeviceOrientation();
}
/// Ensures that Flutter bindings are initialized.
static _ensureInitialized() {
WidgetsFlutterBinding.ensureInitialized();
}
/// Configures the window dimensions for desktop applications.
///
/// Ensures the window manager is initialized and sets a minimum window size.
static _setupWindowDimensions() async {
// Flutter maintains web on its own.
if (kIsWeb || Platform.isAndroid || Platform.isIOS) return;
await windowManager.ensureInitialized();
windowManager.setMinimumSize(const Size(425, 600));
}
/// Configures the device orientation and system UI overlays.
///
/// Locks the device orientation to portrait mode and ensures system
/// UI overlays are manually configured.
static _setupDeviceOrientation() async {
await SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
]);
await SystemChrome.setEnabledSystemUIMode(
SystemUiMode.manual,
overlays: [SystemUiOverlay.bottom, SystemUiOverlay.top],
);
}
}

View File

@@ -0,0 +1,24 @@
import 'package:flutter/material.dart';
/// Extension on [BuildContext] to provide easy access to media query properties.
extension MediaQueryExtensions on BuildContext {
/// Returns `true` if the device width is greater than 768 pixels.
bool get isLargeScreen => MediaQuery.of(this).size.width > 768;
bool get isExtraWideScreen => MediaQuery.of(this).size.width > 1024;
/// Returns `true` if the device width is 768 pixels or less.
bool get isMobile => !isLargeScreen;
/// Returns a scaled width factor based on the screen size.
double widthFactor({
required double mobileFactor,
required double largeScreenFactor,
}) {
return MediaQuery.of(this).size.width *
(isMobile ? mobileFactor : largeScreenFactor);
}
}

View File

@@ -0,0 +1,12 @@
import 'dart:ui';
/// Extension on [Color] to provide additional color manipulation utilities.
extension ColorExtensions on Color {
/// Returns a new color with the given [opacity] applied.
///
/// The [opacity] value should be between `0.0` (fully transparent) and `1.0` (fully opaque).
/// If the value is out of bounds, it is clamped within the valid range.
Color applyOpacity(double opacity) {
return withAlpha((opacity * 255).toInt().clamp(0, 255));
}
}