Skip to content

Disabled TextField InputDecoration errorText allocates space but is not shown #67409

Open
flutter/packages
#12589

Description

@PetrasBartusis

Steps to Reproduce

  1. Create a TextField that has enabled: false and has decoration: InputDecoration().

  2. Code of the sample app:

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) => MaterialApp(
        title: 'Flutter Demo',
        home: MyHomePage(),
      );
}

class MyHomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) => Scaffold(
        body: Center(
          child: Padding(
            padding: EdgeInsets.all(16),
            child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [
              Container(
                color: Colors.green.withOpacity(0.4),
                child: TextField(
                  enabled: false,
                  decoration: InputDecoration(
                    hintText: 'hintText',
                  ),
                ),
              ),
              SizedBox(height: 8),
              Container(
                color: Colors.orange.withOpacity(0.4),
                child: TextField(
                  enabled: false,
                  decoration: InputDecoration(hintText: 'hintText', errorText: 'Error text'),
                ),
              ),
              SizedBox(height: 8),
              Container(
                color: Colors.red.withOpacity(0.4),
                child: TextField(
                  decoration: InputDecoration(hintText: 'hintText', errorText: 'Error text'),
                ),
              ),
            ]),
          ),
        ), // This trailing comma makes auto-formatting nicer for build methods.
      );
}

Expected results:
To my mind, TextField should not allocate the space if it is disabled or it should still display the errorText;

Actual results:
At the moment it allocates the space but does not show the error itself;

Example image:

image

Activity

  1. darshankawar commented on Oct 6, 2020

    @darshankawar
    Member

    Issue replicable on latest stable. Tested on Android 8.1.0.
    If the textfield is disabled that has errorText, the space is rendered even though the text is not, similar to an enabled textfield minus the error text.

    flutter doctor -v
    [✓] Flutter (Channel stable, 1.22.0, on Mac OS X 10.15.4 19E2269, locale en-IN)
        • Flutter version 1.22.0 at /Users/dhs/documents/Fluttersdk/flutter
        • Framework revision d408d302e2 (7 days ago), 2020-09-29 11:49:17 -0700
        • Engine revision 5babba6c4d
        • Dart version 2.10.0
    
     
    [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.0)
        • Android SDK at /Users/dhs/Library/Android/sdk
        • Platform android-30, build-tools 30.0.0
        • Java binary at: /Applications/Android
          Studio.app/Contents/jre/jdk/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build
          1.8.0_242-release-1644-b3-6222593)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 11.5)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Xcode 11.5, Build version 11E608c
        • CocoaPods version 1.9.3
    
    [✓] Android Studio (version 4.0)
        • Android Studio at /Applications/Android Studio.app/Contents
        • Flutter plugin version 46.0.2
        • Dart plugin version 193.7361
        • Java version OpenJDK Runtime Environment (build
          1.8.0_242-release-1644-b3-6222593)
    
    [✓] VS Code (version 1.49.1)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.11.0
    
    [✓] Connected device (1 available)
        • SM A260G (mobile) • 5200763ebcfa861f • android-arm • Android 8.1.0 (API
          27)
    
    • No issues found!
    
    
  2. added
    a: text inputEntering text in a text field or keyboard related problems
    a: typographyText rendering, possibly libtxt
    p: material_uimaterial_ui package in flutter/packages
    frameworkflutter/packages/flutter repository. See also f: labels.
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    on Oct 6, 2020
  3. maheshj01 commented on Nov 25, 2022

    @maheshj01
    Member

    The issue is still reproducible as of the latest stable 3.3 and the master 3.6channel, The error text take space when the error is not present.

    image

    code sample
    import 'package:flutter/material.dart';
    
    void main() => runApp(MyApp());
    
    class MyApp extends StatelessWidget {
      // This widget is the root of your application.
      @override
      Widget build(BuildContext context) => MaterialApp(
            title: 'Flutter Demo',
            home: MyHomePage(),
          );
    }
    
    class MyHomePage extends StatelessWidget {
      @override
      Widget build(BuildContext context) => Scaffold(
            body: Center(
              child: Padding(
                padding: EdgeInsets.all(16),
                child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [
                  Container(
                    color: Colors.green.withOpacity(0.4),
                    child: const TextField(
                      enabled: false,
                      decoration: InputDecoration(
                        hintText: 'hintText',
                      ),
                    ),
                  ),
                const   SizedBox(height: 8),
                  Container(
                    color: Colors.orange.withOpacity(0.4),
                    child:const  TextField(
                      enabled: false,
                      decoration: InputDecoration(hintText: 'hintText', errorText: 'Error text'),
                    ),
                  ),
                 const  SizedBox(height: 8),
                  Container(
                    color: Colors.red.withOpacity(0.4),
                    child: const TextField(
                      decoration: InputDecoration(hintText: 'hintText', errorText: 'Error text'),
                    ),
                  ),
                ]),
              ),
            ),
    
          );
    }
    flutter doctor -v (mac)
    [✓] Flutter (Channel master, 3.6.0-6.0.pre.33, on macOS 12.6 21G115 darwin-arm64,
        locale en-IN)
        • Flutter version 3.6.0-6.0.pre.33 on channel master at
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision a9858ec524 (72 minutes ago), 2022-11-21 10:58:11 -0500
        • Engine revision 46a6b54295
        • Dart version 2.19.0 (build 2.19.0-406.0.dev)
        • DevTools version 2.19.0
        • 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 (Android SDK version 33.0.0-rc4)
        • Android SDK at /Users/mahesh/Library/Android/sdk
        • Platform android-33, build-tools 33.0.0-rc4
        • ANDROID_HOME = /Users/mahesh/Library/Android/sdk
        • Java binary at: /Applications/Android
          Studio.app/Contents/jre/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 14.0.1)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Build 14A400
        • CocoaPods version 1.11.3
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2021.2)
        • Android Studio at /Applications/Android Studio.app/Contents
        • Flutter plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/9212-flutter
        • Dart plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/6351-dart
        • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
    
    [✓] IntelliJ IDEA Community Edition (version 2021.2.1)
        • IntelliJ at /Applications/IntelliJ IDEA CE.app
        • Flutter plugin version 61.2.4
        • Dart plugin version 212.5080.8
    
    [✓] VS Code (version 1.70.2)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.53.20221101
    
    [✓] Connected device (3 available)
        • iPhone 12 Pro (mobile) • 026D5789-9E78-4AD5-B1B2-3F8D4E7F65E4 • ios
          • com.apple.CoreSimulator.SimRuntime.iOS-14-5 (simulator)
        • macOS (desktop)        • macos                                • darwin-arm64
          • macOS 12.6 21G115 darwin-arm64
        • Chrome (web)           • chrome                               • web-javascript
          • Google Chrome 107.0.5304.110
    
    [✓] HTTP Host Availability
        • All required HTTP hosts are available
    
    • No issues found!
    
    [✓] Flutter (Channel stable, 3.3.9, on macOS 12.6 21G115 darwin-arm, locale en-IN)
        • Flutter version 3.3.9 on channel stable at /Users/mahesh/Development/flutter
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision b8f7f1f986 (24 hours ago), 2022-11-23 06:43:51 +0900
        • Engine revision 8f2221fbef
        • Dart version 2.18.5
        • DevTools version 2.15.0
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0-rc4)
        • Android SDK at /Users/mahesh/Library/Android/sdk
        • Platform android-33, build-tools 33.0.0-rc4
        • ANDROID_HOME = /Users/mahesh/Library/Android/sdk
        • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 14.0.1)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Build 14A400
        • CocoaPods version 1.11.3
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2021.2)
        • Android Studio at /Applications/Android Studio.app/Contents
        • Flutter plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/9212-flutter
        • Dart plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/6351-dart
        • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
    
    [✓] IntelliJ IDEA Community Edition (version 2021.2.1)
        • IntelliJ at /Applications/IntelliJ IDEA CE.app
        • Flutter plugin version 61.2.4
        • Dart plugin version 212.5080.8
    
    [✓] VS Code (version 1.70.2)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.53.20221101
    
    [✓] Connected device (3 available)
        • iPhone 12 Pro (mobile) • 026D5789-9E78-4AD5-B1B2-3F8D4E7F65E4 • ios            •
          com.apple.CoreSimulator.SimRuntime.iOS-14-5 (simulator)
        • macOS (desktop)        • macos                                • darwin-arm64   • macOS 12.6 21G115 darwin-arm
        • Chrome (web)           • chrome                               • web-javascript • Google Chrome 107.0.5304.110
    
    [✓] HTTP Host Availability
        • All required HTTP hosts are available
    
    • No issues found!
    
  4. ashimthapa01 commented on Oct 3, 2023

    @ashimthapa01

    what is the update in this issue???

  5. added and removed
    team-designOwned by Design Languages team
    triaged-designTriaged by Design Languages team
    on Mar 12, 2025
  6. added
    P2Important issues not at the top of the work list
    on Mar 13, 2025
  7. added
    packageflutter/packages repository. See also p: labels.
    and removed
    frameworkflutter/packages/flutter repository. See also f: labels.
    on Aug 17, 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

    P2Important issues not at the top of the work lista: text inputEntering text in a text field or keyboard related problemsa: typographyText rendering, possibly libtxtfound in release: 3.3Found to occur in 3.3found in release: 3.6Found to occur in 3.6has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: material_uimaterial_ui package in flutter/packagespackageflutter/packages repository. See also p: labels.team-text-inputOwned by Text Input teamtriaged-text-inputTriaged by Text Input team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions