Skip to content

Flutter Web Crash on Android Chrome - padding.isNonNegative Assertion Error #187345

Closed

Description

@Harpreet-ui

Steps to reproduce

Dear Flutter Team,

I am encountering a runtime assertion error in a Flutter Web application when running on Android Chrome.

Error:

Assertion failed:
file:///C:/flutter/packages/flutter/lib/src/widgets/implicit_animations.dart:912:15
padding.isNonNegative is not true

Issue Description:

The application contains a dialog with TextFields. The error occurs only on Android Chrome when the soft keyboard is opened and closed multiple times.

Steps to Reproduce:

  1. Open the Flutter Web application in Android Chrome.
  2. Open a dialog containing TextFields.
  3. Tap a TextField to open the keyboard.
  4. Close the keyboard.
  5. Reopen the keyboard or interact with the dialog again.
  6. The application throws the assertion mentioned above.

Observations:

  • The issue does not occur on desktop browsers.
  • The error appears to be related to keyboard-triggered MediaQuery updates.
  • The assertion originates from implicit_animations.dart and seems related to a negative EdgeInsets value being passed to an AnimatedPadding or similar widget.
  • The problem is reproducible only in Flutter Web on Android Chrome.

Environment:

  • Flutter Version: [Your Flutter Version]
  • Chrome Version: [Chrome Version]
  • Android Device: [Device Name]
  • Platform: Flutter Web

Could you please advise whether this is a known issue or provide guidance on additional debugging steps?

Thank you for your time and support.

Kind regards,

Harpreet Singh
Flutter Developer

Expected results

Analyze my complete Flutter project and find the exact source of the following runtime error:

Assertion failed:
file:///C:/flutter/packages/flutter/lib/src/widgets/implicit_animations.dart:912:15
padding.isNonNegative is not true

The error occurs specifically on Flutter Web running in Android Chrome. When I open a dialog, tap a TextField, open the mobile keyboard, and then close/open the keyboard, the app throws this assertion.

Tasks:

  1. Scan the entire project for all usages of:

    • Padding
    • AnimatedPadding
    • EdgeInsets.only
    • EdgeInsets.symmetric
    • EdgeInsets.fromLTRB
    • EdgeInsets.all
    • MediaQuery.of(context).viewInsets
    • MediaQuery.of(context).padding
    • MediaQuery.of(context).viewPadding
    • keyboard-related calculations
    • Responsive layout calculations
  2. Identify every place where padding values can become negative due to:

    • screen width calculations
    • screen height calculations
    • keyboard opening/closing
    • MediaQuery changes
    • responsive helper methods
    • subtraction operations such as:
      viewInsets.bottom - X
      screenWidth - X
      screenHeight - X
  3. Add temporary debug logs before every suspicious padding calculation to print:

    • calculated padding values
    • screen width
    • screen height
    • viewInsets.bottom
    • viewPadding values
  4. Trace the widget tree and determine the exact widget causing:
    padding.isNonNegative is not true

  5. Check all custom widgets including:

    • Dashboard
    • ProductCard
    • CartScreen
    • FooterSection
    • ResponsiveScreenFeature
    • All dialogs
    • Any widget using AnimatedContainer or AnimatedPadding
  6. Replace unsafe padding calculations with safe versions using:
    math.max(0, value)
    or
    value.clamp(0.0, double.infinity)

  7. Provide:

    • exact file name
    • exact line number
    • problematic code
    • corrected code
    • explanation of why the padding becomes negative on Android Chrome
  8. Do not stop after finding one issue. Continue scanning the entire project for all possible negative padding sources and list every occurrence.

Goal:
Find and permanently fix the root cause of the Android Chrome keyboard/dialog crash caused by negative padding.

Actual results

The closing of the keyboard is not correct nd make issue in the flutter web page

Code sample

Code sample
[Paste your code here]

Screenshots or Video

<details open>

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[Paste your output here]

Activity

  1. added
    in triage
    on Jun 1, 2026
  2. puneetkukreja98 commented on Jun 1, 2026

    @puneetkukreja98
    Contributor

    @Harpreet-ui Thanks for reporting the issue! To make this issue actionable, we need more information:

    1. MRE: A minimal reproducible example code that we can copy-paste into main.dart and run.
    2. Screenshots/Video.
    3. Error Logs: The complete stack trace or logs showing the error.
    4. Flutter Doctor o/p.
  3. added
    waiting for response
    and removed
    in triage
    on Jun 1, 2026
  4. github-actions commented on Jun 22, 2026

    @github-actions

    Without additional information, we are unfortunately not sure how to resolve this issue. We are therefore reluctantly going to close this bug for now.

    If you find this problem please file a new issue with the same description, what happens, logs and the output of 'flutter doctor -v'. All system setups can be slightly different so it's always better to open new issues and reference the related ones.

    Thanks for your contribution.

  5. Harpreet-ui commented on Jun 22, 2026

    @Harpreet-ui
    Author
  6. Harpreet-ui commented on Jun 22, 2026

    @Harpreet-ui
    Author
  7. Harpreet-ui commented on Jul 7, 2026

    @Harpreet-ui
    Author
  8. github-actions commented on Jul 21, 2026

    @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.

  9. locked as resolved and limited conversation to collaborators on Jul 21, 2026
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

    waiting for response

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions