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
.