September 2019
Beginner
512 pages
12h 52m
English
To use the plugin package, we start by importing it into our Dart libraries,like any other plugin:
import 'package:hands_on_platform_version/hands_on_platform_version.dart';
The usage follows with the plugin method invocation:
await HandsOnPlatformVersion.platformVersion;
The full example retains the platform version in the _platformVersion field and calls the native code in the initPlatformState() method:
Future<void> initPlatformState() async { // 1 String platformVersion; try { // 2 platformVersion = await HandsOnPlatformVersion.platformVersion; } on PlatformException { platformVersion = 'Failed to get platform version.'; } if (!mounted) return; // 3 setState(() { _platformVersion = platformVersion; // 4 }); }
We can ...
Read now
Unlock full access