What Is This?
This is a more advanced version of Platform in Flutter for finding and checking the current platform of the app. It includes stuff like desktop mode, mobile mode, native web, and debug mode.
How to Use
EnvironmentType
EnvironmentType is an enum of platforms with these possible values:
windows: Windowsmacos: macOSlinux: Any Linux distributionios: iOS and iPadOSandroid: Androidweb: Web (WASM or native web)webnative: Web with native web (For when the platform is web without using WASM)wasm: Web with WASMfuchsia: Fuchsia
Environment
EnvironmentType is a class of platform conditions with these functions and values:
Values
isWindows: if the platform is WindowsisMacos: if the platform is macOSisLinux: if the platform is any Linux distributionisIOS: if the platform is iOS or iPadOSisAndroid: if the platform is AndroidisWeb: if the platform is on the web (WASM or native web)isWasm: if the platform is web with WASMisWebNative: if the platform is web with native web (if the platform is web but not WASM)isFuchsia: if the platform is FuchsiaisDesktop: if the platform is Windows, macOS, or LinuxisMobile: if the platform is iOS, iPadOS, or AndroidisApple: if the platform is iOS, iPadOS or macOSisDebug: if the project is in debug modeisRelease: if the projects is in release mode
Functions
format()- Formats a raw EnvironmentType object to proper human-readable format
- Arguments
platform: EnvironmentType (required)- The platform to be formatted
errorOnNotFound: boolean (default: true)- If the function should error if the platform inputted is not found
get()- Gets the current platform as an EnvironmentType
Extra notes
- This package should be compatible with WASM, but for some reason Pana says it's not.
- I wanted a better name, trust me, but most of the ones I wanted were already taken.
Libraries
- api/io
- Handles operations that require dart:io.
- api/null
- Handles cases where imports are unable to use the default import. Contains placeholder and catcher functions.
- flutter_environments_plus
- Base library for managing everything for flutter_environments.