Coding⏱️ 2 min read📅 2026-06-03

How to Fix: When the keyboard appears, the Flutter widgets resize. How to prevent this?

Prevent Flutter widgets from resizing when keyboard appears.

Quick Answer: Use the `keyboardDismissMode` property on your `MaterialApp` widget to prevent widgets from resizing. Set it to `KeyboardDismissMode.onClose`. Alternatively, use `Expanded` with a non-zero initial size to prevent it from expanding to fill available space.

The issue of Flutter widgets resizing when the keyboard appears is a common problem in mobile app development. This occurs because the Expanded widget does not provide any constraints for its child, causing it to expand and fill the available space.

🛑 Root Causes of the Error

  • Insufficient constraints for child widgets in Expanded widget.

🚀 How to Resolve This Issue

Method 1: Using BoxConstraints

  1. Step 1: Wrap your Column widget with a Container and provide BoxConstraints to it.

Method 2: Using Expanded with constraints

  1. Step 1: Provide a constraint to the Expanded widget, for example, using flex or crossAxisExtent.

✨ Wrapping Up

By applying these solutions, you can prevent your Flutter widgets from resizing when the keyboard appears. Remember to always provide sufficient constraints for your child widgets in Expanded widget.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions