8.9 C
London
Wednesday, February 21, 2024

white display on inappwebview after resuming app from background on android and ios?


After I shut the app for round a minute after which transfer it to the background earlier than resuming, the InAppWebView widget is roofed by a white overlay, or it simply does not present the online content material on the display. I can nonetheless work together with the web page that was loaded earlier than the app was suspended, and I can hear sound results that play on the positioning, so it is undoubtedly nonetheless lively ultimately. I am simply confused about how I can get it to truly SHOW the web page after I resume the app. The debug console reveals nothing out of the atypical after I reopen the app from being suspended; it is the very same output as when the InAppWebView was really seen.

I’ve tried making a fundamental implementation of InAppWebView in my app, utilizing a unique URL, working flutter clear, working flutter pub improve, working flutter pub downgrade, and I nonetheless get the problem. This is the code for the web page.

class CustomWebView extends StatefulWidget {
  closing String url;

  CustomWebView({required this.url});

  @override
  _CustomWebViewState createState() => _CustomWebViewState();
}

class _CustomWebViewState extends State<CustomWebView>
    with SingleTickerProviderStateMixin, WidgetsBindingObserver {
  bool _isLoading = true; // Initially, webview is loading
  late InAppWebViewController webcontroller;

  @override
  void initState() {
    tremendous.initState();
  }

  @override
  Widget construct(BuildContext context) {
    return InAppWebView(
      key: Key('webview'),
      initialOptions: InAppWebViewGroupOptions(
        crossPlatform: InAppWebViewOptions(
          transparentBackground: true,
          useShouldOverrideUrlLoading: true,
          supportZoom: true,
        ),
        android: AndroidInAppWebViewOptions(
          builtInZoomControls: true,
          loadWithOverviewMode: true,
          useWideViewPort: true,
        ),
        ios: IOSInAppWebViewOptions(
          disableInputAccessoryView: true,
          allowsInlineMediaPlayback: true,
        ),
      ),
      initialUrlRequest: URLRequest(url: Uri.parse(widget.url)),
      shouldOverrideUrlLoading: (controller, navigationAction) async {
        var uri = navigationAction.request.url!;
        if (uri.toString().accommodates('logout')) {
          logOut(context);
          return NavigationActionPolicy.CANCEL;
        }
        if (uri.toString().accommodates('whatsapp')) {
          var shareText = await getTextParam(uri.toString());
          Share.share(shareText!);
          return NavigationActionPolicy.CANCEL;
        }
        if (uri.toString().accommodates('?process_s=3')) {
          var standing = await Permission.storage.standing;
          if (!standing.isGranted) {
            standing = await Permission.storage.request();
          }
          if (standing.isGranted) {
            Navigator.push(
                context,
                MaterialPageRoute(
                    builder: (context) => GenerateQRPage(
                          url: '',
                        )));
          }
          return NavigationActionPolicy.CANCEL;
        }

        return NavigationActionPolicy.ALLOW;
      },
      onWebViewCreated: (InAppWebViewController controller) {
        webcontroller = controller;
      },
      onLoadStop: (controller, url) async {},
    );
  }
}

Latest news
Related news

LEAVE A REPLY

Please enter your comment!
Please enter your name here