0

i am new here. Please forgive me if I make a mistake. I'm trying to make a payment screen. But I can't solve a small problem. I couldn't understand the cause of the problem. when i click to 'start payment' button it's show me that screen about 2 second.And it's look bad. Bad View

But good news it's skip automatically normal payment screen. How can I show something else(Circular progress indicator, Lineer progres indicator etc.) on the screen instead of that String? My codes are below;

if (data['Status'] != "failure") {
        Navigator.of(context).push(MaterialPageRoute(
            builder: ((context) => CoreWebView(
                  htmlCode: data['paymentUrl'],
                ))));
      }

It's my WebView

    WebViewPlus(
              initialUrl: "https://example.com",
              javascriptMode: JavascriptMode.unrestricted,
              onWebViewCreated: (controller) {
             //widget.html==data['paymentUrl'];
             
                var page = 'r"""${widget.htmlCode}"""';
                controller.loadString(page);
              },
         
           
              zoomEnabled: false,
             
            ),

1 Answers1

0
  1. Make your widget a StatefulWidget.

  2. Add a variable as bool isLoading = true;.

  3. Change your code as:

    Stack(
      children: [
       WebViewPlus(
         onPageFinished: (url) {
           setState(() {
             isLoading = false;
           });
         },
         initialUrl: "https://example.com",
         javascriptMode: JavascriptMode.unrestricted,
         onWebViewCreated: (controller) {
           //widget.html==data['paymentUrl'];
           var page = 'r"""${widget.htmlCode}"""';
           controller.loadString(page);
         },
         zoomEnabled: false,
       ),
       if(isLoading)
         Center(child: CircularProgressIndicator()
       )
     ],
    ),
    
Lalit Fauzdar
  • 5,953
  • 2
  • 26
  • 50