//展示网页数据 class MyWebView extends StatefulWidget { String url; String title; MyWebView({Key key, @required this.url, @required this.title}); @override createState() => _PageState(url: url, title: title); } class _PageState extends State<MyWebView> { String url; String title; _PageState({Key key, @required this.url, @required this.title}); final _key = UniqueKey(); @override void initState() { super.initState(); } @override Widget build(BuildContext context) { return Scaffold( appBar: _setTitle(context), body: Column( children: [ Expanded( child: WebView( key: _key, javascriptMode: JavascriptMode.unrestricted, initialUrl: url)) ], )); } _setTitle(context) { return new AppBar( brightness: Brightness.light, title: new Text(title, style: TextStyle(color: Colors.black, fontSize: 20)), elevation: 1, leading: new IconButton( icon: new Icon( Icons.arrow_back_ios, color: Colors.black, ), onPressed: () { Navigator.pop(context); }), backgroundColor: Colors.white, centerTitle: true, ); } }
flutter webview
最新推荐文章于 2025-06-12 18:06:08 发布