第一步:安装webView
#webview
webview_flutter: ^3.0.2
第二步:写入页面
SizedBox( width: Get.width, height: Get.height, child: Padding( padding: EdgeInsets.only(top: 264.w), child: WebView( initialUrl: controller.url, onWebViewCreated: (WebViewController webViewController) { controller.webViewcController.complete(webViewController); }, javascriptMode: JavascriptMode.unrestricted, backgroundColor: Colors.transparent, javascriptChannels: <JavascriptChannel>[ _rechargeJavascriptChannel(), ].toSet(), )), ),
第三步:写入controller
class PublicWebViewController extends GetxController { String title = ''; String url = ''; final Completer<WebViewController> webViewcController = Completer<WebViewController>(); @override void onClose() { // TODO: implement onClose super.onClose(); if (webViewcController != null && webViewcController.future != null) { webViewcController.future.then((wController) { // wController.clearCache(); }); } } @override void onInit() { // TODO: implement onInit super.onInit(); title = Get.arguments['title']; url = Get.arguments['url']; } }
标签:Get,url,controller,webViewcController,使用,webView,flutter From: https://www.cnblogs.com/liangqilin/p/17766897.html