PlatformUtils class
Utility class for platform-specific value selection.
This class provides a convenient way to select different values based on the current platform (Android, iOS, macOS, Windows, Linux, or Fuchsia). It's useful for platform-specific UI customization, API endpoints, or feature flags.
Example usage:
// Select platform-specific colors
final primaryColor = PlatformUtils.select<Color>(
android: Colors.green,
ios: Colors.blue,
macos: Colors.purple,
fallback: Colors.grey,
);
// Select platform-specific strings
final welcomeMessage = PlatformUtils.select<String>(
android: 'Welcome to Android!',
ios: 'Welcome to iOS!',
fallback: 'Welcome!',
);
// Select platform-specific API endpoints
final apiUrl = PlatformUtils.select<String>(
android: 'https://api.example.com/android',
ios: 'https://api.example.com/ios',
fallback: 'https://api.example.com/default',
);
Constructors
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 Methods
-
select<
T> ({T? android, T? ios, T? macos, T? windows, T? linux, T? fuchsia, required T fallback}) → T - Selects a platform-specific value based on the current platform.