It looks like there has been an update to the flutter_inappwebview
package which now expects a WebUri
instead of a Uri
.
Here's the corrected code:
- Add the
flutter_inappwebview
package to yourpubspec.yaml
file:
yamldependencies:
flutter:
sdk: flutter
flutter_inappwebview: ^6.0.0
- Import the package in your Dart file:
dartimport 'package:flutter/material.dart'; import 'package:flutter_inappwebview/flutter_inappwebview.dart';
- Create a WebView widget to display the web content:
dartclass WebViewScreen extends StatefulWidget { @override _WebViewScreenState createState() => _WebViewScreenState(); } class _WebViewScreenState extends State<WebViewScreen> { InAppWebViewController? webViewController; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('WebView Example'), ), body: InAppWebView( initialUrlRequest: URLRequest( url: WebUri('https://web.footballislife.xyz:8443/tntsports2.php'), ), onWebViewCreated: (controller) { webViewController = controller; }, onLoadStop: (controller, url) async { print("Finished loading: $url"); }, onLoadError: (controller, url, code, message) { print("Error loading: $message"); }, onLoadHttpError: (controller, url, statusCode, description) { print("HTTP error: $statusCode, $description"); }, ), ); } }
- Use the WebViewScreen widget in your application:
dartvoid main() { runApp(MaterialApp( home: WebViewScreen(), )); }