feat(http):http webview top

This commit is contained in:
2025-12-22 11:26:28 +08:00
parent ff3c7402a9
commit 3e2f011463

View File

@@ -45,91 +45,94 @@ class _CustomerWebViewState extends State<CustomerWebView> {
return Stack(
alignment: Alignment.topLeft,
children: [
InAppWebView(
key: webViewKey,
// webViewEnvironment: webViewEnvironment,
initialUrlRequest: URLRequest(url: WebUri(widget.url)),
// initialUrlRequest:
// URLRequest(url: WebUri(Uri.base.toString().replaceFirst("/#/", "/") + 'page.html')),
// initialFile: "assets/index.html",
initialUserScripts: UnmodifiableListView<UserScript>([]),
initialSettings: settings,
// contextMenu: contextMenu,
// pullToRefreshController: pullToRefreshController,
onWebViewCreated: (controller) async {
webViewController = controller;
},
onLoadStart: (controller, url) {
setState(() {
// this.url = url.toString();
// urlController.text = this.url;
});
},
// onPermissionRequest: (controller, request) {
// return PermissionResponse(
// resources: request.resources,
// action: PermissionResponseAction.GRANT);
// },
// shouldOverrideUrlLoading:
// (controller, navigationAction) async {
// var uri = navigationAction.request.url!;
//
// if (![
// "http",
// "https",
// "file",
// "chrome",
// "data",
// "javascript",
// "about"
// ].contains(uri.scheme)) {
// if (await canLaunchUrl(uri)) {
// // Launch the App
// await launchUrl(
// uri,
// );
// // and cancel the request
// return NavigationActionPolicy.CANCEL;
// }
// }
//
// return NavigationActionPolicy.ALLOW;
// },
// onLoadStop: (controller, url) {
// pullToRefreshController?.endRefreshing();
// setState(() {
// this.url = url.toString();
// urlController.text = this.url;
// });
// },
// onReceivedError: (controller, request, error) {
// pullToRefreshController?.endRefreshing();
// },
// onProgressChanged: (controller, progress) {
// if (progress == 100) {
// pullToRefreshController?.endRefreshing();
// }
// setState(() {
// this.progress = progress / 100;
// urlController.text = this.url;
// });
// },
// onUpdateVisitedHistory: (controller, url, isReload) {
// setState(() {
// this.url = url.toString();
// urlController.text = this.url;
// });
// },
onConsoleMessage: (controller, consoleMessage) {
print(consoleMessage);
},
Padding(
padding: const EdgeInsets.only(top: 16,bottom: 16),
child: InAppWebView(
key: webViewKey,
// webViewEnvironment: webViewEnvironment,
initialUrlRequest: URLRequest(url: WebUri(widget.url)),
// initialUrlRequest:
// URLRequest(url: WebUri(Uri.base.toString().replaceFirst("/#/", "/") + 'page.html')),
// initialFile: "assets/index.html",
initialUserScripts: UnmodifiableListView<UserScript>([]),
initialSettings: settings,
// contextMenu: contextMenu,
// pullToRefreshController: pullToRefreshController,
onWebViewCreated: (controller) async {
webViewController = controller;
},
onLoadStart: (controller, url) {
setState(() {
// this.url = url.toString();
// urlController.text = this.url;
});
},
// onPermissionRequest: (controller, request) {
// return PermissionResponse(
// resources: request.resources,
// action: PermissionResponseAction.GRANT);
// },
// shouldOverrideUrlLoading:
// (controller, navigationAction) async {
// var uri = navigationAction.request.url!;
//
// if (![
// "http",
// "https",
// "file",
// "chrome",
// "data",
// "javascript",
// "about"
// ].contains(uri.scheme)) {
// if (await canLaunchUrl(uri)) {
// // Launch the App
// await launchUrl(
// uri,
// );
// // and cancel the request
// return NavigationActionPolicy.CANCEL;
// }
// }
//
// return NavigationActionPolicy.ALLOW;
// },
// onLoadStop: (controller, url) {
// pullToRefreshController?.endRefreshing();
// setState(() {
// this.url = url.toString();
// urlController.text = this.url;
// });
// },
// onReceivedError: (controller, request, error) {
// pullToRefreshController?.endRefreshing();
// },
// onProgressChanged: (controller, progress) {
// if (progress == 100) {
// pullToRefreshController?.endRefreshing();
// }
// setState(() {
// this.progress = progress / 100;
// urlController.text = this.url;
// });
// },
// onUpdateVisitedHistory: (controller, url, isReload) {
// setState(() {
// this.url = url.toString();
// urlController.text = this.url;
// });
// },
onConsoleMessage: (controller, consoleMessage) {
print(consoleMessage);
},
),
),
Visibility(
visible: widget.hideBack != true,
child: GestureDetector(
onTap: () => Navigator.pop(context),
child: Container(
margin: const EdgeInsets.only(left: 16, top: 24),
margin: const EdgeInsets.only(left: 16, top: 28),
width: 44,
height: 44,
decoration: BoxDecoration(