Flutter and YouTube
Flutter and YouTube
All in one Flutter resource: https://flatteredwithflutter.com/how-to-use-youtube-in-flutter/
Free AI web copilot to create summaries, insights and extended knowledge, download it at here
2982
Abstract
ur api key under :</p><figure id="0bc1"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*F36D1k0YMUZkbUc7pwuiyA.png"><figcaption>GCP key…</figcaption></figure><p id="3538">4. Use the following to play a video:</p><div id="fd84"><pre>FlutterYoutube.playYoutubeVideoByUrl( <span class="hljs-symbol"> apiKey:</span> <span class="hljs-string">"YOUR API KEY"</span>, <span class="hljs-symbol"> videoUrl:</span> <span class="hljs-string">"URL TO PLAY"</span>, )<span class="hljs-punctuation">;</span></pre></div><p id="a3ec"><b>Required parameters</b></p><p id="eb61"><b>apiKey</b> : From step 3</p><p id="710e"><b>videoUrl</b> : as per your choice</p><p id="12c6"><b>Optional Parameters:</b></p><p id="5253"><b>fullScreen</b>: false,</p><p id="0c7a"><b>autoPlay</b>: false,</p><blockquote id="4df4"><p><b>If all went successful, you will see video opening as below screenshot</b></p></blockquote><figure id="749f"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*goXMECh2njpqZooViEXsTg.png"><figcaption>Flutter and YouTube…</figcaption></figure><h2 id="bd68">Collecting / Retrieving Data…</h2><p id="092e">For the collection of data, we are using <b>Firestore</b>. For retrieval of data, we are using a package called <a href="https://pub.dartlang.org/packages/cloud_firestore"><b>cloud_firestore</b></a>.</p><h2 id="2d85">Display Data…</h2><p id="3e6a">Parent widget is enclosed using a <b>PageView Builder…</b></p><p id="2e83">If you are not familiar with <b>PageView builder</b>, must-read,</p><blockquote id="e43b"><p><a href="https://readmedium.com/a-deep-dive-into-pageview-in-flutter-with-custom-transitions-581d9ea6dded">https://readmedium.com/a-deep-dive-into-pageview-in-flutter-with-custom-transitions-581d9ea6dded</a></p></blockquote><p id="2cbf">UI can be divided into 2 sections,</p><ol><li>Top section (<b>Wonder Image</b>)</li><li>Bottom section (<b>Wonder Name and Wonder Location</b>)</li></ol><figure id="e86c"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*BUlMg3J6M8ryoHVmd1FR2w.png"><figcaption>Flutter and YouTube…</figcaption></figure><blockquote id="a0bb"><p>Bottom section, uses the Google Maps for showing the location of the current wonder.</p></blockquote><p id="e06e"><b>Not familiar with Google Maps in Flutter, must-read</b></p><blockquote id="0970"><p><a href="https://readmedium.com/flutter-and-google-maps-2b4e332e24ec">https://readmedium.com/flutter-and-google-maps-2b4e332e24ec</a></p></blockquote><p id="4e31">Sample Source code in the link for Google Maps….</p><p id="f825">For setting the location for the wonder, we are using</p><div id="1c38"><pre>mapController.animateCamera( CameraUpdate.<span class="hljs-keyword">new</span><span class="hljs-type">LatLng</span>( LatLng( <span class="hljs-comment">//Latitude of the wonder,</span> <span class="hljs-comment">//Longitude of the wonder,</span> ), ), );</pre></div><blockquote id="e093"><p>Top section, uses the <a h
Options
ref="https://pub.dartlang.org/packages/cached_network_image"><b>CachedNetworkImage</b></a> for requesting the image of the wonder….</p></blockquote><div id="c951"><pre>CachedNetworkImage( <span class="hljs-name">imageUrl</span>: <span class="hljs-string">"YOUR URL"</span>, <span class="hljs-name">placeholder</span>: <span class="hljs-function"><span class="hljs-params">(context, url)</span> =></span> CircularProgressIndicator(), <span class="hljs-name">errorWidget</span>: <span class="hljs-function"><span class="hljs-params">(context, url, <span class="hljs-built_in">error</span>)</span> =></span> Icon(Icons.<span class="hljs-built_in">error</span>), ),</pre></div><blockquote id="d9fe"><p>The image widget is then wrapped into<b> <a href="https://docs.flutter.io/flutter/material/InkWell-class.html">InkWell</a> </b>for listening<b> to the click/tap events…</b></p></blockquote><p id="eadf">and on this tap event, we are eventually calling the<b> YouTube Player</b>…:)</p><p id="7022">Articles related to Flutter:</p><div id="0587" class="link-block"> <a href="https://readmedium.com/flutter-web-and-navigation-history-3feec04bfc80"> <div> <div> <h2>Flutter Web and Navigation History</h2> <div><h3>Flutter Web and Navigation History. Store navigation history</h3></div> <div><p>medium.com</p></div> </div> <div> <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/1*tVALfcJ4eNI3yMjFWWl_lA.jpeg)"></div> </div> </div> </a> </div><div id="a01f" class="link-block"> <a href="https://readmedium.com/flutter-provider-and-streams-33b401ebe28c"> <div> <div> <h2>Flutter Provider and Streams</h2> <div><h3>Using Streams in Provider Flutter. Check now!</h3></div> <div><p>medium.com</p></div> </div> <div> <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/1*-sXimkCot3rUFOHrYRbhSA.png)"></div> </div> </div> </a> </div><div id="8465" class="link-block"> <a href="https://readmedium.com/flutter-and-ar-a65bb202c5d8"> <div> <div> <h2>Flutter and AR</h2> <div><h3>Is everything already virtual ?</h3></div> <div><p>medium.com</p></div> </div> <div> <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/1*Fd8kkp_SIl45hdYkEioq3g.png)"></div> </div> </div> </a> </div><p id="6184">Phew…..!</p><figure id="cccd"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*rpTl0ep9orbTrbRhvOmw-w.gif"><figcaption></figcaption></figure></article></body>
Flutter and YouTube
All in one Flutter resource: https://flatteredwithflutter.com/how-to-use-youtube-in-flutter/
What if the videos on YouTube app, can be viewed on Flutter….Hmmmm
Flutterers, (term coined by me), as we can see are growing,
According to LinkedIn, Flutter, is among the fastest growing skills for software engineers
So, are the packages for the dart….One such package that caught my attention was flutter_youtube…
And yes it supports both

The app which we demonstrate below is showing seven wonders of the world. It can be broken down into :

flutter_youtube: "^1.1.6"2. Import the package as
import 'package:flutter_youtube/flutter_youtube.dart';3. Specify your apiKey,
apiKey -> is the google credentials key for your project (GCP project)
You can find your api key under :

4. Use the following to play a video:
FlutterYoutube.playYoutubeVideoByUrl(
apiKey: "YOUR API KEY",
videoUrl: "URL TO PLAY",
);Required parameters
apiKey : From step 3
videoUrl : as per your choice
Optional Parameters:
fullScreen: false,
autoPlay: false,
If all went successful, you will see video opening as below screenshot

For the collection of data, we are using Firestore. For retrieval of data, we are using a package called cloud_firestore.
Parent widget is enclosed using a PageView Builder…
If you are not familiar with PageView builder, must-read,
https://readmedium.com/a-deep-dive-into-pageview-in-flutter-with-custom-transitions-581d9ea6dded
UI can be divided into 2 sections,

Bottom section, uses the Google Maps for showing the location of the current wonder.
Not familiar with Google Maps in Flutter, must-read
Sample Source code in the link for Google Maps….
For setting the location for the wonder, we are using
mapController.animateCamera(
CameraUpdate.newLatLng(
LatLng(
//Latitude of the wonder,
//Longitude of the wonder,
),
),
);Top section, uses the CachedNetworkImage for requesting the image of the wonder….
CachedNetworkImage(
imageUrl: "YOUR URL",
placeholder: (context, url) => CircularProgressIndicator(),
errorWidget: (context, url, error) => Icon(Icons.error),
),The image widget is then wrapped into InkWell for listening to the click/tap events…
and on this tap event, we are eventually calling the YouTube Player…:)
Articles related to Flutter:
Phew…..!
