main.dart 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. import 'package:chewie/chewie.dart';
  2. import 'package:flutter/cupertino.dart';
  3. import 'package:flutter/material.dart';
  4. void main() => runApp(new ChewieDemo());
  5. class ChewieDemo extends StatefulWidget {
  6. final String title;
  7. ChewieDemo({this.title = 'Chewie Demo'});
  8. @override
  9. State<StatefulWidget> createState() {
  10. return new _ChewieDemoState();
  11. }
  12. }
  13. class _ChewieDemoState extends State<ChewieDemo> {
  14. TargetPlatform _platform;
  15. @override
  16. Widget build(BuildContext context) {
  17. return new MaterialApp(
  18. title: widget.title,
  19. theme: new ThemeData.light().copyWith(
  20. platform: _platform ?? Theme.of(context).platform,
  21. ),
  22. home: new Scaffold(
  23. appBar: new AppBar(
  24. title: new Text(widget.title),
  25. ),
  26. body: new Column(
  27. children: <Widget>[
  28. new Expanded(
  29. child: new Center(
  30. child: new Chewie(
  31. 'https://flutter.github.io/assets-for-api-docs/videos/butterfly.mp4',
  32. aspectRatio: 3 / 2,
  33. autoPlay: true,
  34. looping: true,
  35. // Try playing around with some of these other options:
  36. // progressColors: new VideoProgressColors(
  37. // playedColor: Colors.red,
  38. // handleColor: Colors.blue,
  39. // disabledColor: Colors.grey,
  40. // bufferedColor: Colors.lightGreen,
  41. // ),
  42. // placeholder: new Container(
  43. // color: Colors.grey,
  44. // ),
  45. // autoInitialize: true,
  46. ),
  47. ),
  48. ),
  49. new Row(
  50. children: <Widget>[
  51. new Expanded(
  52. child: new FlatButton(
  53. onPressed: () {
  54. setState(() {
  55. _platform = TargetPlatform.android;
  56. });
  57. },
  58. child: new Padding(
  59. child: new Text("Android controls"),
  60. padding: new EdgeInsets.symmetric(vertical: 16.0),
  61. ),
  62. )),
  63. new Expanded(
  64. child: new FlatButton(
  65. onPressed: () {
  66. setState(() {
  67. _platform = TargetPlatform.iOS;
  68. });
  69. },
  70. child: new Padding(
  71. padding: new EdgeInsets.symmetric(vertical: 16.0),
  72. child: new Text("iOS controls"),
  73. ),
  74. ),
  75. )
  76. ],
  77. )
  78. ],
  79. ),
  80. ),
  81. );
  82. }
  83. }