Saturday, May 11, 2024
HomeiOS DevelopmentFlutter WebView reveals white display on iOS

Flutter WebView reveals white display on iOS


I wish to use the WebView in Flutter to load a code redemption web page from apple, in order that my consumer can use reductions on subscriptions. For instance pages like Google, Flutter.dev, … it really works high quality, however utilizing the url from apple sadly will not. I simply get a clean white display in my physique – the appbar works high quality. What could possibly be fallacious?

import 'bundle:flutter/materials.dart';
import 'bundle:url_launcher/url_launcher.dart';
import 'bundle:webview_flutter/webview_flutter.dart';
import '../../configuration/theme.dart';


class FumiProPromoPage extends StatefulWidget {
  String code;
  //Variable Code übergeben
  FumiProPromoPage({
    Key? key,
    required this.code,
  }) : tremendous(key: key);

  @override
  State<FumiProPromoPage> createState() => _FumiProPromoPageState();
}

class _FumiProPromoPageState extends State<FumiProPromoPage> {
  var loadingPercentage = 0;
  late WebViewController controller;
  remaining GlobalKey webViewKey = GlobalKey();

  String promourl = "https://google.de";
  String url = "";
  double progress = 0;
  remaining urlController = TextEditingController();


  @override
  void initState() {
    tremendous.initState();
    promourl="https://apps.apple.com/redeem?ctx=offercodes&id=1567964963&code=${widget.code}";
    print(promourl);

    controller = WebViewController()
    ..setJavaScriptMode(JavaScriptMode.unrestricted)
    ..setBackgroundColor(const Coloration(0x00000000))
    ..setNavigationDelegate(
      NavigationDelegate(
        onProgress: (int progress) {
          // Replace loading bar.
        },
        onPageStarted: (String url) {},
        onPageFinished: (String url) {},
        onWebResourceError: (WebResourceError error) {},
        onNavigationRequest: (NavigationRequest request) {
          if (request.url.startsWith('https://www.youtube.com/')) {
            return NavigationDecision.stop;
          }
          return NavigationDecision.navigate;
        },
      ),
    )
    ..loadRequest(Uri.parse(promourl));
  }
  Widget construct(BuildContext context) {
    
    return Scaffold(
      appBar: AppBar(
            elevation: 0,
            backgroundColor: fumigruenAccent,
            title: const Textual content(
              "Promocode einlösen",
              fashion: TextStyle(
                colour: Colours.black,
              ),
            ),
            main: CloseButton(
              colour: Colours.black,
              onPressed: () {
                Navigator.of(context).pop();
              },
            ),),
        
        
      physique: 
      
      Stack(
        kids: [
          WebViewWidget(
            controller: controller,
          ), 
          
          loadingPercentage < 100
              ? LinearProgressIndicator(
                  color: Colors.red,
                  value: loadingPercentage / 100.0,
                )
              : Container()
        ],
      ), 
    );
  }
}

I additionally deactivated the Apple Transport Safety (ATS) function for http requests to determine if that is the issue. It sadly did not work.

To do that I added the next traces to my Data.plist

<key>NSAppTransportSecurity</key>
<dict>
  <key>NSAllowsArbitraryLoads</key><true/>
</dict>

Any concepts? many thanks prematurely!



Supply hyperlink

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments