12345678910111213141516171819202122232425262728293031 |
- import 'dart:io';
- import 'package:flutter/cupertino.dart';
- import 'package:flutter/foundation.dart';
- class DeviceUtils {
- static bool get isDesktop => !isWeb && (isWindows || isLinux || isMacOS);
- static bool get isMobile => isAndroid || isIOS;
- static bool get isWeb => kIsWeb;
- static bool get isWindows => !isWeb && Platform.isWindows;
- static bool get isLinux => !isWeb && Platform.isLinux;
- static bool get isMacOS => !isWeb && Platform.isMacOS;
- static bool get isAndroid => !isWeb && Platform.isAndroid;
- static bool get isFuchsia => !isWeb && Platform.isFuchsia;
- static bool get isIOS => !isWeb && Platform.isIOS;
- static bool isDarkMode(BuildContext context) {
- Brightness currentBrightness = MediaQuery.of(context).platformBrightness;
- return currentBrightness == Brightness.dark;
- }
- }
|