platform_specific library
Dart package that simplifies handling platform-specific operations and callbacks in your Dart/Flutter applications.
Example usage:
final myValue = Platforms.on<String>(
{
PlatformTypes.android: () {
return '🤖';
},
PlatformTypes.windows: () {
return '🪟';
},
PlatformTypes.oneOf([PlatformTypes.iOS, PlatformTypes.macOS]): () {
return '🍎';
}
},
orElse: () {
return 'unknown';
},
);
print(myValue); // Output: 🍎 (if running on iOS or macOS), 🤖 (if running on Android), 🪟 (if running on Windows), or 'unknown' (if running on any other platform)
Classes
- Platforms
- A utility class for platform-specific operations and callbacks.
- PlatformType
- Abstract class representing a platform type.
- PlatformTypes
- A collection of different platform types.
Typedefs
-
PlatformCallback<
T> = T Function() -
Callback for a function that returns
T
.