youtube_player_iframe_web 3.1.1 copy "youtube_player_iframe_web: ^3.1.1" to clipboard
youtube_player_iframe_web: ^3.1.1 copied to clipboard

Platformweb
unlisted

Web implementation of webview_flutter plugin tailored for using with youtube_player_iframe package.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';
import 'package:youtube_player_iframe/youtube_player_iframe.dart';

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Youtube Player Iframe Web Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Youtube Player Iframe Web Demo'),
        ),
        body: SingleChildScrollView(
          padding: const EdgeInsets.all(32),
          child: SizedBox(
            height: 1000,
            child: LayoutBuilder(
              builder: (context, constraints) {
                if (constraints.maxWidth < 600) {
                  return const Column(
                    children: [
                      PlayerWidget(),
                      Divider(),
                      Expanded(child: _WebViewWidget()),
                    ],
                  );
                }

                return const Row(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Expanded(child: PlayerWidget()),
                    VerticalDivider(),
                    Expanded(child: _WebViewWidget()),
                  ],
                );
              },
            ),
          ),
        ),
      ),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    return YoutubePlayer(
      controller: YoutubePlayerController.fromVideoId(
        videoId: 'gCRNEJxDJKM',
        params: const YoutubePlayerParams(
          showControls: true,
          showFullscreenButton: true,
        ),
      ),
      aspectRatio: 16 / 9,
    );
  }
}

class _WebViewWidget extends StatefulWidget {
  const _WebViewWidget();

  @override
  State<_WebViewWidget> createState() => _WebViewWidgetState();
}

class _WebViewWidgetState extends State<_WebViewWidget> {
  @override
  void initState() {
    super.initState();
    _controller = WebViewController()..loadRequest(Uri.https('flutter.dev'));
  }

  late final WebViewController _controller;

  @override
  Widget build(BuildContext context) {
    return WebViewWidget(controller: _controller);
  }
}
2
likes
150
pub points
84%
popularity

Publisher

verified publishersarbagyastha.com.np

Web implementation of webview_flutter plugin tailored for using with youtube_player_iframe package.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-2-Clause (license)

Dependencies

flutter, flutter_web_plugins, web, webview_flutter_platform_interface

More

Packages that depend on youtube_player_iframe_web