import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; import 'package:webview_flutter/webview_flutter.dart'; class NewsDetailPage extends StatefulWidget { String? id; NewsDetailPage({Key? key, this.id}) : super(key: key); @override State createState() => NewsDetailPageState(id: this.id); } class NewsDetailPageState extends State { String? id; bool loaded = false; String? detailDataStr; NewsDetailPageState({Key? key, this.id}); @override void initState() { super.initState(); } @override Widget build(BuildContext context) { WebViewController webViewController = WebViewController() ..setUserAgent("Android OSC") ..setJavaScriptMode(JavaScriptMode.unrestricted) ..setBackgroundColor(const Color(0x00000000)) ..setNavigationDelegate( NavigationDelegate( onProgress: (int progress) { // Update loading bar. }, onPageStarted: (String url) {}, onPageFinished: (String url) {}, onWebResourceError: (WebResourceError error) {}, ), ) ..loadRequest(Uri.parse(widget.id!)); List titleContent = []; titleContent.add(Text( "资讯详情", style: TextStyle(color: Colors.white), )); if (!loaded) { titleContent.add(CupertinoActivityIndicator()); } titleContent.add(Container(width: 50.0)); return WebViewWidget( controller: webViewController, ); } }