1

I try to know phone operating system if IOS or android in flutter app is running on it through:

  @override
  void initState() {
    super.initState();
    }

In order to set if condition after the operating system is detected. How can I control this? Does anyone know a solution to this problem?

marwan marwan
  • 171
  • 3
  • 7
  • 4
    Does this answer your question? [How do you detect the host platform from Dart code?](https://stackoverflow.com/questions/45924474/how-do-you-detect-the-host-platform-from-dart-code) – dh4ze Nov 06 '20 at 08:57

1 Answers1

4
import 'dart:io' show Platform;

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

Check the docs:

https://api.flutter.dev/flutter/dart-io/Platform-class.html

Peter Haddad
  • 78,874
  • 25
  • 140
  • 134
Ayush Surana
  • 1,776
  • 1
  • 12
  • 16