main.dart 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import 'dart:async';
  2. import 'package:flutter/material.dart';
  3. import 'package:umeng_analytics_plugin/umeng_analytics_plugin.dart';
  4. void main() => runApp(MyApp());
  5. class MyApp extends StatefulWidget {
  6. @override
  7. _MyAppState createState() => _MyAppState();
  8. }
  9. class _MyAppState extends State<MyApp> {
  10. String _platformVersion = 'Unknown';
  11. @override
  12. void initState() {
  13. super.initState();
  14. initPlatformState();
  15. }
  16. Future<void> initPlatformState() async {
  17. var result = await UmengAnalyticsPlugin.init(
  18. androidKey: '5dfc5b91cb23d26df0000a90',
  19. iosKey: '5dfc5c034ca35748d1000c4c',
  20. );
  21. print('Umeng initialized.');
  22. if (!mounted) {
  23. return;
  24. }
  25. setState(() {
  26. _platformVersion = result ? 'OK' : 'ERROR';
  27. });
  28. }
  29. @override
  30. Widget build(BuildContext context) {
  31. return MaterialApp(
  32. home: Scaffold(
  33. appBar: AppBar(
  34. title: const Text('Plugin example app'),
  35. ),
  36. body: Center(
  37. child: Text('Running on: $_platformVersion\n'),
  38. ),
  39. ),
  40. );
  41. }
  42. }