platform_specific

Last updated:

0 purchases

platform_specific Image
platform_specific Images
Add to Cart

Description:

platform specific

Platform Specific #



Dart package that simplifies handling platform-specific operations and callbacks in your Dart/Flutter applications.
Features ๐Ÿš€ #

Execute platform-specific callback functions based on the detected platform type.
Define custom platform types to handle specific platforms.
Supports a wide range of platforms out of the box including web, Windows, Linux, Android, macOS, Fuchsia, and iOS.

Usage ๐Ÿงช #
Use the Platforms.on method to execute the appropriate callback function based on the platform:
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)

copied to clipboard
Custom Platform Types #
You can create custom platform types by extending the PlatformType class and overriding the isPlatform method. This allows you to handle additional platforms not covered by the predefined types.
class MyCustomPlatform extends PlatformType {
const MyCustomPlatform();

@override
bool isPlatform(PlatformType? override) {
// Add your custom platform detection logic here
// Should return true if override == this
...
}
}
copied to clipboard

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.