youtube_video_webview 1.0.4 copy "youtube_video_webview: ^1.0.4" to clipboard
youtube_video_webview: ^1.0.4 copied to clipboard

A customizable YouTube video player for Flutter, supporting embedded playback, fullscreen mode, sharing, captions, and seamless redirection to YouTube inside a webview.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:youtube_video_webview/youtube_video_webview.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'YouTube Video Webview Example',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const Simple(),
    );
  }
}

class Simple extends StatelessWidget {
  const Simple({super.key});

  @override
  Widget build(BuildContext context) {
    return YoutubeVideoWebview(
      videoId: 'Pj2miRJ6bZs',
      referrerHeader: 'https://www.google.com',
    );
  }
}


class DragToDismiss extends StatelessWidget {
  const DragToDismiss({super.key});

  @override
  Widget build(BuildContext context) {
    return YoutubeVideoWebview(
      videoId: '<ENTER_VIDEO_ID>',
      referrerHeader: '<ENTER_REFERRER_URL>',
      externalBrowserSettings: YoutubePageWebViewSettings(
        dragToDismiss: true
      ),
    );
  }
}


class DefaultAppBar extends StatelessWidget {
  const DefaultAppBar({super.key});

  @override
  Widget build(BuildContext context) {
    return YoutubeVideoWebview(
      videoId: '<ENTER_VIDEO_ID>',
      referrerHeader: '<ENTER_REFERRER_URL>',
      externalBrowserSettings: YoutubePageWebViewSettings(
        appBar: YoutubeVideoWebviewAppBarDefault(),
      ),
    );
  }
}


class ShareAppBar extends StatelessWidget {
  const ShareAppBar({super.key});

  @override
  Widget build(BuildContext context) {
    return YoutubeVideoWebview(
      videoId: '<ENTER_VIDEO_ID>',
      referrerHeader: '<ENTER_REFERRER_URL>',
      externalBrowserSettings: YoutubePageWebViewSettings(
        appBar: YoutubeVideoWebviewAppBarShare(
          videoId: '<ENTER_VIDEO_ID>',
          shareText: "Check out this video!",
        ),
      ),
    );
  }
}


class CustomAppBar extends StatelessWidget {
  const CustomAppBar({super.key});

  @override
  Widget build(BuildContext context) {
    return YoutubeVideoWebview(
      videoId: '<ENTER_VIDEO_ID>',
      referrerHeader: '<ENTER_REFERRER_URL>',
      externalBrowserSettings: YoutubePageWebViewSettings(
        appBar: YoutubeVideoWebviewAppBarCustom(
          appBar: AppBar(
            title: const Text('Custom App Bar'),
            backgroundColor: Colors.green,
          ),
        ),
      ),
    );
  }
}
0
likes
150
points
207
downloads

Publisher

unverified uploader

Weekly Downloads

A customizable YouTube video player for Flutter, supporting embedded playback, fullscreen mode, sharing, captions, and seamless redirection to YouTube inside a webview.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, share_plus, webview_flutter

More

Packages that depend on youtube_video_webview