{"id":609,"date":"2023-02-18T19:47:38","date_gmt":"2023-02-18T11:47:38","guid":{"rendered":"http:\/\/gjweb.top\/?p=609"},"modified":"2023-02-18T19:47:38","modified_gmt":"2023-02-18T11:47:38","slug":"25-flutter-%e6%92%ad%e6%94%be%e8%a7%86%e9%a2%91","status":"publish","type":"post","link":"https:\/\/gjweb.top\/?p=609","title":{"rendered":"25. flutter \u64ad\u653e\u89c6\u9891"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u4f9d\u8d56\u7684\u7ec4\u4ef6<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>dependencies:<br>  video_player: ^2.5.1<br>  chewie: ^1.4.0<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u4f7f\u7528<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import 'package:chewie\/chewie.dart';<br>import 'package:video_player\/video_player.dart';<br>\u200b<br>final videoPlayerController = VideoPlayerController.network(<br> &nbsp; &nbsp;'https:\/\/flutter.github.io\/assets-for-api-docs\/assets\/videos\/butterfly.mp4');<br>await videoPlayerController.initialize();<br>final chewieController = ChewieController(<br> &nbsp;videoPlayerController: videoPlayerController,<br> &nbsp;autoPlay: true,<br> &nbsp;looping: true,<br> &nbsp; &nbsp;optionsBuilder:(context,defaultOptions)async{<br> &nbsp; &nbsp; &nbsp; &nbsp;return await showModalBottomSheet(<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;context:context,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;builder:(context){<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;      ListView(<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;      children:&#91;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ListTile(<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;      title:const Text(\"\u64ad\u653e\u901f\u5ea6\"),<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ontap:(){<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\/\/ defaultOptions \u5efa\u8bae\u6253\u5370\u4e00\u4e0b\u68c0\u67e5onTap\u7684\u4e0b\u6807<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;defaultOptions&#91;0].onTap!()<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  ),<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ListTile(<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;      title:const Text(\"\u53d6\u6d88\"),<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ontap:(){<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Navigator.of(context).pop();<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  }<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  ),<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  ]<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  )<br> &nbsp; &nbsp; &nbsp;      }<br> &nbsp; &nbsp; &nbsp;  )<br> &nbsp;  }<br>);<br>\u200b<br>final playerWidget = Chewie(<br> &nbsp;controller: chewieController,<br>);<br>\u200b<br>\/\/ \u9500\u6bc1<br>@override<br>void dispose() {<br> &nbsp;videoPlayerController.dispose();<br> &nbsp;chewieController.dispose();<br> &nbsp;super.dispose();<br>}<br>\u200b<br>\u200b<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u4f9d\u8d56\u7684\u7ec4\u4ef6 \u4f7f\u7528<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[31],"tags":[],"class_list":["post-609","post","type-post","status-publish","format-standard","hentry","category-flutter"],"_links":{"self":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts\/609","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=609"}],"version-history":[{"count":1,"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts\/609\/revisions"}],"predecessor-version":[{"id":610,"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts\/609\/revisions\/610"}],"wp:attachment":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=609"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=609"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=609"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}