PlatformIs class
A universal platform checker.
Can be used to check active physical Flutter platform on all platforms.
To check what host platform the app is running on use:
- PlatformIs.android
- PlatformIs.iOS
- PlatformIs.macOS
- PlatformIs.windows
- PlatformIs.linux
- PlatformIs.fuchsia
To check the device type use:
- PlatformIs.mobile (Android or iOS)
- PlatformIs.desktop (Windows, macOS or Linux)
Currently Fuchsia is not considered mobile nor desktop, even if it might be so in the future.
To check if the Flutter application is running on Web you can use:
- PlatformIs.web
Alternatively the Flutter foundation compile time constant kIsWeb also works well for that.
The platform checks are supported independently on web. You can use PlatformIs windows, iOS, macOS, Android and Linux to check what the host platform is when you are running a Flutter Web application.
Checking if we are running on a Fuchsia host in a Web browser, is not yet fully supported. If running in a Web browser on Fuchsia, PlatformIs.web will be true, but PlatformIs.fuchsia will be false. Future versions, when Fuchsia is released, may fix this.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- android → bool
-
Android
no setter
- desktop → bool
-
Desktop (Windows, macOS, Linux)
no setter
- fuchsia → bool
-
Fuchsia
no setter
- iOS → bool
-
iOS
no setter
- linux → bool
-
Linux desktop
no setter
- macOS → bool
-
Mac OS desktop
no setter
- mobile → bool
-
Mobile (Android or iOS)
no setter
- web → bool
-
Web
no setter
- windows → bool
-
Windows desktop
no setter