Skip to content

[WEB] Flutter rendering breaks if embedded iframe is covered by on screen keyboard (android chrome browser) #173128

Closed as duplicate

Description

@jmandawg

Steps to reproduce

If you have an embedded iframe on your flutter page, if the onscreen keyboard covers any part of the iframe flutter rendering breaks.

Build a project with the code below for WEB, run the code on an android device with chrome browser, scroll down so the iframe will be covered/partially covered by the onscreen keyboard when you click on the iframe input field. Observe rednering is broken.

Expected results

Flutter redering should work properly

Actual results

cannot view iframe content and flutter

rendering is broken

Code sample

Code sample

main.dart

import 'package:flutter/material.dart';
import 'dart:html';
import 'dart:ui' as ui;

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: SingleChildScrollView(
          child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Container(
              width: 550,
              height: 500,
              color: Color(0xFFFF0000)
              
              ),
            IframeLoginWidget(),
            Container(
              width: 550,
              height: 1000,
              color: Color(0xFF00FF00)
              
              )
          ],
        ),
        ),
      ),
    );
  }
}

class IframeLoginWidget extends StatefulWidget {

  const IframeLoginWidget({super.key});


  @override
  // ignore: no_logic_in_create_state
  State<IframeLoginWidget> createState() => _IframeLoginWidgetState();
} 

class _IframeLoginWidgetState extends State<IframeLoginWidget> {
  

  _IframeLoginWidgetState();

  

  final IFrameElement _iFrameElement = IFrameElement();

  @override
  void initState() {

    _iFrameElement.style.height = '200px';
    //_iFrameElement.style.width = '400px';
    _iFrameElement.src = 'frame.html';
    //_iFrameElement.style.border = 'none';
    //_iFrameElement.style.overflow = 'hidden';
    _iFrameElement.setAttribute('scrolling', 'no');
    
    // ignore: undefined_prefixed_name
    ui.platformViewRegistry.registerViewFactory(
      'iframeElement',
      (int viewId) => _iFrameElement,
    );

    super.initState();
  }

  final Widget _iframeWidget = HtmlElementView(
    viewType: 'iframeElement',
    key: UniqueKey(),
  );

  @override
  Widget build(BuildContext context) {
    return SingleChildScrollView(
      child: Column(
        children: [
          SizedBox(
            height: 200,
            width: 400,
            child: _iframeWidget,
          ),
        Container(
          height: 50,
          color: Color.fromARGB(0, 232, 248, 239),
          child: Text('this is flutter text'),
        ),
        ],
      )
    );
  }
}

web/frame.html

<!DOCTYPE html>
<html>
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
/* The Modal (background) */
.modal {
  display: block; /* Hidden by default */
  width: 100%; /* Full width */
  height: 100%; /* Full height */
  overflow: auto; /* Enable scroll if needed */
  background-color: rgb(0,0,0); /* Fallback color */
  background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
  padding-top: 0px;
}


</style>
  </head>
<body>

<h2>HTML Iframes</h2>
<div id="id01" class="modal">
  <form class="modal-content animate" action="/action_page.php" method="post">
    <div class="container">
      <label for="uname"><b>Username</b></label>
      <input type="text" placeholder="Enter Username" name="uname" required>
      <br>

      <label for="psw"><b>Password</b></label>
      <input type="password" placeholder="Enter Password" name="psw" required>

      <button type="submit">Login</button>
      <label>
        <input type="checkbox" checked="checked" name="remember"> Remember me
      </label>
    </div>

    <div class="container" style="background-color:#f1f1f1">
      <button type="button" onclick="document.getElementById('id01').style.display='none'" class="cancelbtn">Cancel</button>
      <span class="psw">Forgot <a href="#">password?</a></span>
    </div>
  </form>
</div>


</body>
</html>

Screenshots or Video

Actual Results:

flutter-render-not-working_small.mp4

Expected Results:

pure-html-working-correctly.mp4
Screenshots / Video demonstration I've included a pure html implementation video to demonstrate how it should work.

[Upload media here]

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
flutter doctor -v
[!] Flutter (Channel [user-branch], 3.29.3, on macOS 15.4.1 24E263 darwin-arm64, locale en-US) [161ms]
    ! Flutter version 3.29.3 on channel [user-branch] at /Users/johnmoon/tools/flutter
      Currently on an unknown channel. Run `flutter channel` to switch to an official channel.
      If that doesn't fix the issue, reinstall Flutter by following instructions at https://flutter.dev/setup.
    ! Upstream repository unknown source is not a standard remote.
      Set environment variable "FLUTTER_GIT_URL" to unknown source to dismiss this error.
    • Framework revision ea121f8859 (4 months ago), 2025-04-11 19:10:07 +0000
    • Engine revision cf56914b32
    • Dart version 3.7.2
    • DevTools version 2.42.3
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.

[✗] Android toolchain - develop for Android devices [122ms]
    ✗ ANDROID_HOME = /Users/johnmoon/Library/Android/sdk
      but Android SDK not found at this location.

[✓] Xcode - develop for iOS and macOS (Xcode 16.4) [506ms]
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16F6
    • CocoaPods version 1.16.2

[✓] Chrome - develop for the web [12ms]
    • CHROME_EXECUTABLE = /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[!] Android Studio (not installed) [11ms]
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/to/macos-android-setup for detailed instructions).

[✓] VS Code (version 1.102.2) [11ms]
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.116.0

[✓] Connected device (4 available) [5.8s]
    • iPhone 16 (mobile)              • 912B0BC9-2572-435E-8500-417D80F4EEB7 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-18-5 (simulator)
    • macOS (desktop)                 • macos                                • darwin-arm64   • macOS 15.4.1 24E263 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad                • darwin         • macOS 15.4.1 24E263 darwin-arm64
    • Chrome (web)                    • chrome                               • web-javascript • Google Chrome 138.0.7204.184
    ! Error: Browsing on the local area network for John Moon’s iPhone. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)

[✓] Network resources [224ms]
    • All expected network resources are available.

! Doctor found issues in 3 categories.

Activity

  1. changed the title [-][WEB] multiple issues with iframe embedded in flutter on mobile browsers[/-] [+][WEB] Flutter rendering breaks if embedded iframe is covered by on screen keyboard (android chrome browser)[/+] on Aug 2, 2025
  2. added
    in triage
    on Aug 4, 2025
  3. tirth-patel-nc commented on Aug 4, 2025

    @tirth-patel-nc
    Member

    Thanks for the report @jmandawg. I think you are hitting #124205 so please follow-up in it for further updates.
    Closing this as a duplicate. If you disagree, write in comments and I'll reopen it.

  4. added
    r: duplicate
    and removed
    in triage
    on Aug 4, 2025
  5. github-actions commented on Aug 18, 2025

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  6. locked as resolved and limited conversation to collaborators on Aug 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    r: duplicate

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions