Flutter plugin for mofun flutter video.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import 'dart:async';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter/services.dart';
  4. import 'package:mofun_flutter_plugin_video/mofun_flutter_plugin_video.dart';
  5. import 'package:mofun_flutter_plugin_video/mofun_video_view.dart';
  6. void main() => runApp(MyApp());
  7. class MyApp extends StatefulWidget {
  8. @override
  9. _MyAppState createState() => _MyAppState();
  10. }
  11. class _MyAppState extends State<MyApp> {
  12. String _platformVersion = 'Unknown';
  13. @override
  14. void initState() {
  15. super.initState();
  16. initPlatformState();
  17. }
  18. // Platform messages are asynchronous, so we initialize in an async method.
  19. Future<void> initPlatformState() async {
  20. String platformVersion;
  21. // Platform messages may fail, so we use a try/catch PlatformException.
  22. try {
  23. platformVersion = await MofunFlutterPluginVideo.platformVersion;
  24. } on PlatformException {
  25. platformVersion = 'Failed to get platform version.';
  26. }
  27. // If the widget was removed from the tree while the asynchronous platform
  28. // message was in flight, we want to discard the reply rather than calling
  29. // setState to update our non-existent appearance.
  30. if (!mounted) return;
  31. setState(() {
  32. _platformVersion = platformVersion;
  33. });
  34. }
  35. @override
  36. Widget build(BuildContext context) {
  37. return MaterialApp(
  38. home: Scaffold(
  39. appBar: AppBar(
  40. title: const Text('Plugin example app'),
  41. ),
  42. body: Column(
  43. children: <Widget>[
  44. Container(
  45. alignment: Alignment.center,
  46. height: 48,
  47. child: Text('Running on: $_platformVersion'),
  48. ),
  49. Container(
  50. height: 100.0,
  51. child: MofunVideoView(
  52. onMofunVideoViewCreated: _onMofunVideoViewCreated,
  53. ),
  54. ),
  55. ],
  56. ),
  57. ),
  58. );
  59. }
  60. }
  61. void _onMofunVideoViewCreated(MofunVideoViewController controller) {
  62. controller.setText('Hello from Android!');
  63. }