flutter plugin for zebra multiplatform sdk

main.dart 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import 'package:flutter/material.dart';
  2. import 'dart:async';
  3. import 'package:flutter/services.dart';
  4. import 'package:flutter_zsdk/flutter_zsdk.dart';
  5. void main() {
  6. runApp(const MyApp());
  7. }
  8. class MyApp extends StatefulWidget {
  9. const MyApp({super.key});
  10. @override
  11. State<MyApp> createState() => _MyAppState();
  12. }
  13. class _MyAppState extends State<MyApp> {
  14. String _platformVersion = 'Unknown';
  15. final _flutterZsdkPlugin = FlutterZsdk();
  16. @override
  17. void initState() {
  18. super.initState();
  19. initPlatformState();
  20. }
  21. // Platform messages are asynchronous, so we initialize in an async method.
  22. Future<void> initPlatformState() async {
  23. String platformVersion;
  24. // Platform messages may fail, so we use a try/catch PlatformException.
  25. // We also handle the message potentially returning null.
  26. try {
  27. platformVersion =
  28. await _flutterZsdkPlugin.getPlatformVersion() ?? 'Unknown platform version';
  29. } on PlatformException {
  30. platformVersion = 'Failed to get platform version.';
  31. }
  32. // If the widget was removed from the tree while the asynchronous platform
  33. // message was in flight, we want to discard the reply rather than calling
  34. // setState to update our non-existent appearance.
  35. if (!mounted) return;
  36. setState(() {
  37. _platformVersion = platformVersion;
  38. });
  39. }
  40. @override
  41. Widget build(BuildContext context) {
  42. return MaterialApp(
  43. home: Scaffold(
  44. appBar: AppBar(
  45. title: const Text('Plugin example app'),
  46. ),
  47. body: Center(
  48. child: Text('Running on: $_platformVersion\n'),
  49. ),
  50. ),
  51. );
  52. }
  53. }