English 中文(简体)
带有板块的虚假载荷屏幕的磁盘移动式网络概览
原标题:Flutter Mobile Webview Iframe with keyboard falsely reloads screen

当使用网上盘点——面盘包装时,把屏幕复读和键盘点到一个投入领域时,就永远不会出现。 该机通常按预期运作,除非点击援引键盘的外地。

复制的样本代码:

import  package:webview_flutter/webview_flutter.dart ;

class PaymentWebView extends StatefulWidget {
  static const path = "payments-web-view";
  final String url;
  const PaymentWebView({super.key, required this.url});

  @override
  State<PaymentWebView> createState() => _PaymentWebViewState();
}

class _PaymentWebViewState extends State<PaymentWebView> {
  final controller = WebViewController()
    ..setBackgroundColor(const Color(0x00000000));
  // ..setNavigationDelegate(
  //   NavigationDelegate(
  //     onProgress: (int progress) {
  //       // Update loading bar.
  //     },
  //     onPageStarted: (String url) {},
  //     onPageFinished: (String url) {},
  //     onWebResourceError: (WebResourceError error) {},
  //     onNavigationRequest: (NavigationRequest request) {
  //       return NavigationDecision.navigate;
  //     },
  //   ),
  // );

  @override
  void initState() {
    Future.microtask(() {
      final size = MediaQuery.of(context).size;
      final height = (size.height * 0.7).toInt().toString();
      final width = (size.width * 0.9).toInt().toString();
      controller.loadRequest(Uri.dataFromString(   <html>
            <head><meta name="viewport" content="width=device-width, initial-scale=1"></head><iframe src="${widget.url}" height=${height}px width=${width}px ></iframe></html>   ,
          mimeType:  text/html ));

    });

    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    print("Refreshed webview");
    return Scaffold(
      body: WebViewWidget(controller: controller),
    );
  }
}

问题回答

我通过将控制员的初始化工作移至内地国来解决这一问题:

class _YourScreen extends State<YourScreen> {
  final String _url;

  final WebViewController _controller = WebViewController();
  _YourScreen(this._url);
  @override
  void initState() {
    super.initState();
    _controller
      ..setJavaScriptMode(JavaScriptMode.unrestricted)
      ..setBackgroundColor(Colors.grey[100]!)
/////// other code ........
}




相关问题
Sending data using Jquery Iframes

I want to send large amounts of data to and from 2 domains (e.g. Cross Domains) I was told the best way to do this is to use IFrames. My question is... How do I go about doing this. Is this what ...

Back button loop with IFRAMES

In my (school) website we use Iframes to display class blogs (on blogger). This works well EXCEPT if the user then clicks on (say) a photo inside the iframe. Blogger (in this case) then displays the ...

Including HTML fragments in a page - methods?

This is an extension of an earlier questions I asked, here: Django - Parse XML, output as HTML fragments for iFrame? Basically, we re looking at integrating various HTML fragments into a page. We ...

Internet Explorer, How to change iframes src

For some reasons I m using an Iframe to display googlemaps, when I want to change it s content I m just changing the Iframe src using JQuery. $( #ggMap ).attr( src , http://newurl.com ); Apparently ...

better way to create dynamic iframes in jQuery?

So I have the following code which is doing a setInterval until the iframe is available to be written to. $( #testdiv ).append( $( <iframe id="testiframe"/> ) ); var t = setInterval(function(){...

Cross browser way of setting IFrame to "about:blank"?

Does anybody know a proper, cross-browser way to "empty" an IFrame? Is "about:blank" recognized without error across all browsers? Is it valid to give an IFrame an empty src?

热门标签