| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- import 'package:flutter/material.dart';
- import 'package:webview_flutter/webview_flutter.dart';
- class WebView extends StatelessWidget{
- late final WebViewController controller;
- WebView({super.key, required String url}){
- controller = WebViewController()
- ..setJavaScriptMode(JavaScriptMode.unrestricted)
- ..setBackgroundColor(const Color(0x00000000))
- ..setNavigationDelegate(
- NavigationDelegate(
- onProgress: (int progress) {
- // Update loading bar.
- },
- onPageStarted: (String url) {},
- onPageFinished: (String url) {},
- onWebResourceError: (WebResourceError error) {},
- // onNavigationRequest: (NavigationRequest request) {
- // if (request.url.startsWith('https://www.youtube.com/')) {
- // return NavigationDecision.prevent;
- // }
- // return NavigationDecision.navigate;
- // },
- ),
- )
- ..loadRequest(Uri.parse(url));
- }
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- appBar: AppBar(title: const Text('')),
- body: WebViewWidget(controller: controller),
- );
- }
- }
|