Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter - Webview_plugin - I can't enable full screen with video

I use a flutter_webview_plugin to display the web page in the application, but when there is a video on the page there is no option to enable the full screen. Does anyone know how to solve this problem? Maybe some other plugin to display the page in the application?

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

String url = "https://youtube.com/";

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Webview Example',
      theme: ThemeData.dark(),
      routes: {
        "/": (_) => Home(),
        "/webview": (_) => WebviewScaffold(
          url: url,
          appBar: AppBar(
            title: Text("WebView"),
          ),
          withJavascript: true,
          withLocalStorage: true,
          withZoom: true,
        )
      },
    );
  }
}

//Rest of the code

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text("WebView"),
        ),
        body: Center(
          child: Column(
            children: <Widget>[
              Container(
                padding: EdgeInsets.all(10.0),
                child: TextField(
                  controller: controller,
                ),
              ),
              RaisedButton(
                child: Text("Open Webview"),
                onPressed: () {
                  Navigator.of(context).pushNamed("/webview");
                },
              )
            ],
          ),
        )
    );
  }
}
like image 539
Captivity Avatar asked Mar 03 '26 23:03

Captivity


1 Answers

You can try my plugin flutter_inappbrowser (EDIT: it has been renamed to flutter_inappwebview).

An example with a youtube video is presented below:

...

child: InAppWebView(
  initialUrl: "https://www.youtube.com/watch?v=sPW7nDBqt8w",
  initialHeaders: {},
  initialOptions: InAppWebViewWidgetOptions(
      inAppWebViewOptions: InAppWebViewOptions(
        debuggingEnabled: true,
      )
  ),
  onWebViewCreated: (InAppWebViewController controller) {
    webView = controller;
  },
  onLoadStart: (InAppWebViewController controller, String url) {

  },
  onLoadStop: (InAppWebViewController controller, String url) {

  },
),

...
like image 156
Lorenzo Pichilli Avatar answered Mar 06 '26 14:03

Lorenzo Pichilli



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!