123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- 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<StatefulWidget> createState() => NewsDetailPageState(id: this.id);
- }
- class NewsDetailPageState extends State<NewsDetailPage> {
- 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<Widget> titleContent = [];
- titleContent.add(Text(
- "资讯详情",
- style: TextStyle(color: Colors.white),
- ));
- if (!loaded) {
- titleContent.add(CupertinoActivityIndicator());
- }
- titleContent.add(Container(width: 50.0));
- return WebViewWidget(
- controller: webViewController,
- );
- }
- }
|