flutter get platform code example

Example 1: check if is android flutter

import 'dart:io' show Platform;

if (Platform.isAndroid) {
  // Android-specific code
} else if (Platform.isIOS) {
  // iOS-specific code
}

Example 2: flutter check ios or android

bool isIOS = Theme.of(context).platform == TargetPlatform.iOS;
bool isAndroid = Theme.of(context).platform == TargetPlatform.android;

Example 3: flutter get platform type

import 'dart:io' show Platform;

Platform.isAndroid;
Platform.isFuchsia;
Platform.isIOS;
Platform.isLinux;
Platform.isMacOS;
Platform.isWindows;

Tags:

Dart Example