52 lines
1.4 KiB
Dart
52 lines
1.4 KiB
Dart
import 'package:flutter/foundation.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:get/get.dart';
|
|
|
|
/// AppScreen class
|
|
class AppScreen {
|
|
static double get screenWidth => _viewSize.width;
|
|
static double get screenHeight => _viewSize.height;
|
|
// static double get screenWidth => MediaQuery.of(Get.context!).size.width;
|
|
// static double get screenHeight => MediaQuery.of(Get.context!).size.height;
|
|
|
|
static Size size(BuildContext context) {
|
|
return MediaQuery.of(context).size;
|
|
}
|
|
|
|
static bool get isDebug => kDebugMode;
|
|
|
|
static double get statusBarHeight => Get.statusBarHeight / Get.pixelRatio;
|
|
|
|
static double get bottomBarHeight => Get.bottomBarHeight / Get.pixelRatio;
|
|
|
|
// static double get tabBarHeight => kToolbarHeight;
|
|
|
|
static double get navBarHeight => kToolbarHeight + statusBarHeight;
|
|
|
|
static bool get isDark => Get.isDarkMode;
|
|
|
|
static bool get isAndroid {
|
|
return GetPlatform.isAndroid;
|
|
}
|
|
|
|
static bool get isIos {
|
|
return GetPlatform.isIOS;
|
|
}
|
|
|
|
static Size get _viewSize {
|
|
if (Get.context != null) {
|
|
return MediaQuery.of(Get.context!).size;
|
|
}
|
|
|
|
final view = WidgetsBinding.instance.platformDispatcher.views.first;
|
|
return view.physicalSize / view.devicePixelRatio;
|
|
}
|
|
|
|
static double aRatioWidth({double? h, double aspectRatio = 1}) {
|
|
h ??= screenHeight;
|
|
return screenHeight * 1 / aspectRatio;
|
|
}
|
|
|
|
static double get keyboardHeight => Get.mediaQuery.viewInsets.bottom;
|
|
}
|