Files
localsend/lib/util/platform_check.dart
2023-01-27 13:46:23 +01:00

36 lines
1.1 KiB
Dart

import 'package:flutter/foundation.dart';
bool checkPlatform(List<TargetPlatform> platforms, {bool web = false}) {
if (web && kIsWeb) {
return true;
}
return platforms.contains(defaultTargetPlatform);
}
/// This platform runs on a "traditional" computer
bool checkPlatformIsDesktop() {
return checkPlatform([TargetPlatform.linux, TargetPlatform.windows, TargetPlatform.macOS]);
}
/// This platform supports tray
/// On linux, this is currently not supported
bool checkPlatformHasTray() {
return checkPlatform([TargetPlatform.windows, TargetPlatform.macOS]);
}
/// This platform can receive share intents
bool checkPlatformCanReceiveShareIntent() {
return checkPlatform([TargetPlatform.android, TargetPlatform.iOS]);
}
/// This platform has a gallery
bool checkPlatformWithGallery() {
return checkPlatform([TargetPlatform.android, TargetPlatform.iOS]);
}
/// This platform has access to file system
/// On android, do not allow to change
bool checkPlatformWithFileSystem() {
return checkPlatform([TargetPlatform.linux, TargetPlatform.windows, TargetPlatform.android, TargetPlatform.macOS]);
}