I'm using webview_flutter_web library for loading the url in webview (for flutter web-build), when i'm trying to load to load https://www.youtube.com/, it's not loading showing error as refused to connect. please support to resolve this issue thank you in advance.
import 'dart:async';
import 'dart:typed_data';
import 'package:flutter/material.dart';
import 'package:webview_flutter_platform_interface/webview_flutter_platform_interface.dart';
import 'package:webview_flutter_web/webview_flutter_web.dart';
class WebViewExample extends StatefulWidget {
const WebViewExample({Key? key}) : super(key: key);
@override
_WebViewExampleState createState() => _WebViewExampleState();
}
class _WebViewExampleState extends State<WebViewExample> {
late double screenWidth;
late double screenHeight;
final PlatformWebViewController _controller = PlatformWebViewController(
const PlatformWebViewControllerCreationParams(),
)..loadRequest(
LoadRequestParams(
uri: Uri.parse('https://www.youtube.com/'),
),
);
@override
Widget build(BuildContext context) {
screenWidth = MediaQuery.of(context).size.width;
screenHeight = MediaQuery.of(context).size.height;
if (screenWidth >= 1024) {
screenWidth = screenWidth * 0.6;
} else if (screenWidth >= 768 && screenWidth <= 1024) {
screenWidth = screenWidth * 0.8;
} else if (screenWidth >= 600) {
screenWidth = screenWidth * 0.5;
} else {
screenWidth = screenWidth;
}
return Scaffold(
appBar: AppBar(
title: const Text('Flutter WebView example'),
),
body: Center(
child: SizedBox(
width: screenWidth,
height: screenHeight,
child: PlatformWebViewWidget(
PlatformWebViewWidgetCreationParams(controller: _controller),
).build(context),
),
),
);
}
}