2024-08-26 12:26:07 +00:00
|
|
|
import 'dart:io';
|
|
|
|
|
|
|
|
import 'package:flutter/foundation.dart';
|
|
|
|
import 'package:package_info_plus/package_info_plus.dart';
|
|
|
|
|
|
|
|
abstract class PlatformInfo {
|
|
|
|
static bool get isWeb => kIsWeb;
|
|
|
|
|
|
|
|
static bool get isLinux => !kIsWeb && Platform.isLinux;
|
|
|
|
|
2024-08-27 07:22:18 +00:00
|
|
|
static bool get isInFlatpak =>
|
2024-08-27 08:37:31 +00:00
|
|
|
kIsWeb ? false : Platform.environment['FLATPAK_ID'] != null;
|
2024-08-27 07:22:18 +00:00
|
|
|
|
2024-08-26 12:26:07 +00:00
|
|
|
static bool get isWindows => !kIsWeb && Platform.isWindows;
|
|
|
|
|
|
|
|
static bool get isMacOS => !kIsWeb && Platform.isMacOS;
|
|
|
|
|
|
|
|
static bool get isIOS => !kIsWeb && Platform.isIOS;
|
|
|
|
|
|
|
|
static bool get isAndroid => !kIsWeb && Platform.isAndroid;
|
|
|
|
|
|
|
|
static bool get isMobile => isAndroid || isIOS;
|
|
|
|
|
|
|
|
// Not first tier supported platform
|
|
|
|
static bool get isBetaDesktop => isWindows || isLinux;
|
|
|
|
|
|
|
|
static bool get isDesktop => isLinux || isWindows || isMacOS;
|
|
|
|
|
|
|
|
static bool get useTouchscreen => !isMobile;
|
|
|
|
|
|
|
|
static bool get canCacheImage => isAndroid || isIOS || isMacOS;
|
|
|
|
|
|
|
|
static bool get canRecord => (isMobile || isMacOS);
|
|
|
|
|
|
|
|
static bool get canPushNotification => isAndroid || isIOS || isMacOS;
|
|
|
|
|
|
|
|
static Future<String> getVersion() async {
|
|
|
|
var version = kIsWeb ? 'Web' : 'Unknown';
|
|
|
|
try {
|
|
|
|
version = (await PackageInfo.fromPlatform()).version;
|
|
|
|
} catch (_) {}
|
|
|
|
return version;
|
|
|
|
}
|
|
|
|
}
|