check os flutter code example
Example 1: check if is android flutter
import 'dart:io' show Platform;
if (Platform.isAndroid) {
} else if (Platform.isIOS) {
}
Example 2: detect os in flutter
import 'dart:io' show Platform, stdout;
void main() {
String os = Platform.operatingSystem;
if (Platform.isMacOS) {
print('is a Mac');
} else {
print('is not a Mac');
}
}
Example 3: flutter check ios or android
bool isIOS = Theme.of(context).platform == TargetPlatform.iOS;
bool isAndroid = Theme.of(context).platform == TargetPlatform.android;