getPlatformVersion method
Retrieves the platform version (e.g., Android 10 or iOS 14). This method communicates with the native platform to fetch the version.
Implementation
@override
Future<String?> getPlatformVersion() async {
try {
// Invoke the native method to get the platform version
final version = await methodChannel.invokeMethod<String>(
'getPlatformVersion',
);
return version;
} on PlatformException catch (e) {
// Handle any platform exception if the method fails
throw 'Failed to get platform version: ${e.message}';
}
}