Home

Published

- 1 min read

detect os in flutter

img of detect os in flutter

The solution for this is noted below

detect os in flutter

Solution

   import 'dart:io' show Platform, stdout;

void main() {
  // Get the operating system as a string.
  String os = Platform.operatingSystem;
  // Or, use a predicate getter.
  if (Platform.isMacOS) {
    print('is a Mac');
  } else {
    print('is not a Mac');
  }
}

Try other methods by searching on the site. That is if this doesn’t work