flutter项目需要加载报表的解决方案 下载包 webview_flutter: ^0.3.19+7
实现公共的webview组件 class CustomWebView extends StatefulWidget {
final String title;
final String url;
CustomWebView({
this.title,
this.url,
});
@override
State createState() => _CustomWebView();
}
class _CustomWebView extends State {
String baseUrl = HttpManager().BASEURL;
_CustomWebView();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: CustomAppBar(
titleText: '报表',
actions: [
Container(
margin: EdgeInsets.only(
right: 10,
),
child: CustomIcon(
icon: Icons.share,
color: CustomColor.white,
size: 25,
ontap: () {
},
),
)
],
),
body: Builder(builder: (BuildContext context) {
return WebView(
initialUrl: '${baseUrl}${widget.url}',
javascriptMode: JavascriptMode.unrestricted,
onWebViewCreated: (WebViewController webViewController) {},
gestureNavigationEnabled: true,
);
}),
);
}
}
|