Skip to content

Android content not scroll up when keyboard is open #2493

@AdilHypeteq

Description

@AdilHypeteq

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

InAppWebViewSettings settings = InAppWebViewSettings(
isInspectable: true,
mediaPlaybackRequiresUserGesture: false,
allowsInlineMediaPlayback: true,
iframeAllowFullscreen: true,
clearCache: true,
clearSessionCache: true,
alwaysBounceVertical: true,
scrollbarFadingEnabled: false,
alwaysBounceHorizontal: true,
javaScriptEnabled: true,
javaScriptCanOpenWindowsAutomatically: true,
useHybridComposition: false);

  Scaffold(
        appBar: AppBar(toolbarHeight: 0),
        resizeToAvoidBottomInset: true,
        drawer: const SideDrawer(),
        body: Column(
          children: [
            AppBarWidget(startPointOfUrl: widget.startPointUrl),
            const SizedBox(height: 10),
            Expanded(
              child: Stack(
                children: [
                  InAppWebView(
                    key: webViewKey,
                    initialUrlRequest:
                        URLRequest(url: WebUri(provider.webViewUrl)),
                    initialSettings: settings,
                    pullToRefreshController: pullToRefreshController,
                    onWebViewCreated: (controller) {
                      provider.webViewController = controller;
                      //controller.platform.clearHistory();
                      // provider.webViewControllerAssign(controller);
                    },
                    onLoadStart: (controller, url) {
                      print("controller,onLoadStart");
                      if (url != WebUri(provider.webViewUrl)) {
                        controller.loadUrl(
                            urlRequest: URLRequest(
                          url: WebUri(provider.webViewUrl),
                        ));
                        // provider.webViewControllerAssign(controller);
                        provider.webViewController = controller;
                      }
                      setState(() {
                        this.url = url.toString();
                      });
                    },
                    onWindowFocus: (controller) {
                      controller.resume();
                    },
                    onRequestFocus: (controller) {
                      print("controller,onRequestFocus");
                    },
                    onWindowBlur: (controller) {
                      print("controller,onWindowBlur");
                    },
                    onPermissionRequest: (controller, request) async {
                      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) async {
                      pullToRefreshController?.endRefreshing();
                    },
                    onReceivedServerTrustAuthRequest:
                        (controller, challenge) async {
                      return ServerTrustAuthResponse(
                          action:
                              ServerTrustAuthResponseAction.PROCEED);
                    },
                    onReceivedError: (controller, request, error) {
                      pullToRefreshController?.endRefreshing();
                    },
                    onProgressChanged: (controller, progress) {
                      setState(() {
                        this.progress = progress / 100;
                      });
                      if (progress == 100) {
                        pullToRefreshController?.endRefreshing();
                      }
                    },
                    onUpdateVisitedHistory:
                        (controller, url, androidIsReload) {
                      print("onUpdateVisitedHistory->$url");
                    },
                    onConsoleMessage: (controller, consoleMessage) {
                      print("consoleMessage $consoleMessage");
                      if (consoleMessage.message
                          .contains('"code":498')) {
                        ShowSnackBar.showSnackBar(
                            text:
                                "Your session has expired. Please login again.",
                            backgroundColor: context.colorScheme.error);
                        PreferenceService preferenceService =
                            PreferenceService.instance;
                        preferenceService.setIsLogin(false);
                        preferenceService.clear();
                        context.navigator.pushNamedAndRemoveUntil(
                            LoginScreen.route, (route) => false);
                      }
                    },
                    onDownloadStartRequest:
                        (controller, downloadRequest) async {
                      final url = downloadRequest.url.toString();
                      print("Download pdf -> $url");

                      await canLaunchUrl(Uri.parse(url))
                          ? await launchUrl(Uri.parse(url))
                          : throw 'Could not launch $url';
                    },
                  ),
                  if (progress < 1.0)
                    LinearProgressIndicator(
                      value: progress,
                      backgroundColor: Colors.transparent,
                      valueColor: const AlwaysStoppedAnimation<Color>(
                          AppColor.primary),
                    ),
                ],
              ),
            ),
          ],
        ),
      )

Expected Behavior

Android content not scroll up when keyboard is open

Steps with code example to reproduce

Steps with code example to reproduce
// Paste your code here

Stacktrace/Logs

Stacktrace/Logs
<Replace this line by pasting your stacktrace or logs here>

Flutter version

'>=3.3.0 <4.0.0'

Operating System, Device-specific and/or Tool

30 and 34

Plugin version

6.1.5

Additional information

No response

Self grab

  • I'm ready to work on this issue!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions