Show Embed YouTube Video in Flutter Android iOS App Example

In flutter we cannot integrate YouTube videos directly. To embed YouTube videos in flutter application we have to use a custom flutter package known as youtube_player_flutter 7.0.0+7 . Guys this package comes with many different functions including custom player options. With this package we can play single YouTube video, Live stream from YouTube channel and also we would play channel list. So in this tutorial we would learn about How to Show Embed YouTube Video in Flutter Android iOS App Example.

Setup Instructions :-

1. For Android :- You have to set minSdkVersion to 17 in your flutter app android/app/build.gradle file.

2. for iOS :- You have to set below key in your info.plist file.

Contents in this project Show Embed YouTube Video in Flutter Android iOS App Example:-

1. Open your flutter project’s pubspec.yaml file in any code editor, I’m using Visual Studio Code Editor for flutter coding.

2. Now put below code after dependencies block to download and install the youtube_player_flutter like I did in below example.

Below is my own pubspec.yaml file after making changes:-

3. Now open your flutter project root directory in Command Prompt in windows and In Terminal in MAC and execute flutter pub get command to download and installed the newly imported package.

4. Now all the installation part has done. Next step is to start coding for app. So open your project’s main.dart file and import material.dart and youtube_player_flutter.dart package.

5. Creating void main runApp() method and here we would call our main MyApp class.

6. Creating our main MyApp extends StatelessWidget class. In this class we would call App() class.

7. Creating our Child class App extends StatelessWidget. In this class we would implement the YouTube video player coding.

8. Complete source code for main.dart file:

Screenshots:

Show Embed YouTube Video in Flutter Android iOS App Example

Leave a Reply

Your email address will not be published. Required fields are marked *