Skip to content

Proposal - content Padding in textFormField under inputDecoration affects errorText #181755

Closed

Description

@Suraj260801

Steps to reproduce

1.copy/ paste the provided code.
2.Run the code in any simulator/emulator.
3.press the submit button

Expected results

contentPadding should affect the actual content entered by user or hint-text present inside the text field.
not the errorText specially. for errorText there should be separate errorPadding property be there which will add more customization to TextFormFields.

Actual results

contentPadding->InputDecoration->TextFormField is affecting the content inside the text field as well as the error text outside the field which in turns creating the ambiguity between the propertyName and text which it affecting.
property says contentPadding but also adding padding to errorText which is visually not part of TextField content.

Code sample

Code sample
import 'package:flutter/material.dart';

class TestFormField extends StatelessWidget {
  TestFormField({super.key});
  final GlobalKey<FormState> _key=GlobalKey<FormState>();

  @override
  Widget build(BuildContext context) {
    final Size size = MediaQuery.sizeOf(context);
    return Scaffold(
      body: Container(
        height: size.height,
        width: size.width,
        alignment: Alignment.center,
        padding: const EdgeInsets.all(16.0),
        child: Form(
          key: _key,
          autovalidateMode: AutovalidateMode.onUserInteraction,
          child: SizedBox(
            width: size.width/2,
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              spacing: 20,
              children: [
                TextFormField(
                  validator: (value) => value == null || value.isEmpty ? 'Please enter some text' : null,
                  decoration: const InputDecoration(
                    labelText: 'Enter text',
                    border: OutlineInputBorder(),
                    contentPadding: EdgeInsets.all(0)
                  ),
                ),

                ElevatedButton(onPressed: (){
                  if(_key.currentState!.validate()){
                    print('Valid');
                  }
                }, child: Text('Submit'))
              ],
            ),
          ),
        ),
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration

This screenshot the contentPadding is 30.

Image

This screenshot the contentPadding is 0.

Image

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.35.7, on macOS 15.1 24B83 darwin-arm64, locale en-IN)
[✗] Android toolchain - develop for Android devices
    ✗ cmdline-tools component is missing.
      Try installing or updating Android Studio.
      Alternatively, download the tools from https://developer.android.com/studio#command-line-tools-only and make sure to set the ANDROID_HOME environment
      variable.
      See https://developer.android.com/studio/command-line for more details.
[!] Xcode - develop for iOS and macOS (Xcode 16.1)
    ✗ CocoaPods not installed.
        CocoaPods is a package manager for iOS or macOS platform code.
        Without CocoaPods, plugins will not work on iOS or macOS.
        For more info, see https://flutter.dev/to/platform-plugins
      For installation instructions, see https://guides.cocoapods.org/using/getting-started.html#installation
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.2)
[✓] Android Studio (version 2024.1)
[✓] Android Studio (version 3.1)
[✓] VS Code (version 1.106.3)
[✓] Connected device (2 available)
[✓] Network resources

! Doctor found issues in 2 categories.

Activity

  1. bilaldev05 commented on Jan 31, 2026

    @bilaldev05

    Hi 👋,
    I'd like to work on separating contentPadding from errorText.
    I’ll investigate how InputDecoration handles padding and propose a fix.

  2. Suraj260801 commented on Jan 31, 2026

    @Suraj260801
    Author

    @bilaldev05 Thanks for taking this up!
    I’m happy to collaborate —feel free to reach out if you need any context or clarification.

  3. puneetkukreja98 commented on Feb 9, 2026

    @puneetkukreja98
    Contributor

    Hey @Suraj260801 , in my opinion this isn’t a bug. It looks more like an enhancement request or a proposal. I’ll forward it to the relevant team.

  4. changed the title [-]content Padding in textFormField under inputDecoration affects errorText[/-] [+]Proposal - content Padding in textFormField under inputDecoration affects errorText[/+] on Feb 9, 2026
  5. added
    c: new featureNothing broken; request for a new capability
    c: proposalA detailed proposal for a change to Flutter
    p: material_uimaterial_ui package in flutter/packages
    and removed
    in triagePresently being triaged by the triage team
    on Feb 9, 2026
  6. MohanadAbdallah-mv commented on Feb 10, 2026

    @MohanadAbdallah-mv
    Contributor

    Hey @puneetkukreja98 , does that mean we will have to wait for flutter team to work on it or review it and give it additional labels or contributors can still work on that issue ?

  7. puneetkukreja98 commented on Feb 10, 2026

    @puneetkukreja98
    Contributor

    @MohanadAbdallah-mv You can also contribute to the issue. You can leave a comment saying that you’re interested, and the team will assign it to you afterward.

  8. added and removed on Feb 10, 2026
  9. justinmc commented on Feb 10, 2026

    @justinmc
    Contributor

    Moving this to the text input team. I'm pretty sure I've seem a similar issue on GitHub recently, I'll post it if I find it.

  10. MohanadAbdallah-mv commented on Feb 11, 2026

    @MohanadAbdallah-mv
    Contributor

    I have identified where the error padding happens.

    on reviewing the text_form_field I found out that errorText use InputDecoration “effectiveDecoration” variable

    /// packages/flutter/lib/src/material/text_form_field.dart -> line 214
    InputDecoration effectiveDecoration = (decoration ?? const InputDecoration())
                   .applyDefaults(InputDecorationTheme.of(field.context));
               final String? errorText = field.errorText;
               if (errorText != null) {
                 effectiveDecoration = errorBuilder != null
                     ? effectiveDecoration.copyWith(error: errorBuilder(state.context, errorText))
                     : effectiveDecoration.copyWith(errorText: errorText);
               }

    so the problem isn’t with defining error padding or separate error InputDeocration for the error inside TextFormField,
    InputDecoration itself need to be modified.

    at input_decorator.dart -> performLayout method
    the responsible code snippet for padding or layout in that case is

    /// packages/flutter/lib/src/material/input_decorator.dart -> line 1434
            start = contentPadding.start + _boxSize(icon).width;
            end = overallWidth - contentPadding.end;
            _boxParentData(helperError).offset = Offset(
            start + decoration.inputGap,
            subtextBaseline - helperErrorBaseline,
            );

    when i tried to modify it to that

    /// packages/flutter/lib/src/material/input_decorator.dart -> line 1434
            start = contentPadding.start + _boxSize(icon).width;
            startError =  _boxSize(icon).width; //will consider separate variable for errorPadding
            end = overallWidth - contentPadding.end;
            _boxParentData(helperError).offset = Offset(
             startError + decoration.inputGap,
             subtextBaseline - helperErrorBaseline,
            ); 

    I got that result

    Image

    As far as I know separating errorText padding will take effect on every descendent widget that use Inputdecoration so we will have to verify with the tests the new layout for each one of them .

    Hope that was helpful,
    Let me know if my theory is correct or if we will take in consideration that generalizing that solution will be good idea or not as I would like to keep investigating and work on this issue .

  11. Renzo-Olivares commented on Feb 12, 2026

    @Renzo-Olivares
    Contributor

    Going to close this as a duplicate of #175834, please feel free to re-open if this is not the case.

  12. github-actions commented on Feb 26, 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.

  13. locked as resolved and limited conversation to collaborators on Feb 26, 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

    c: new featureNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to Flutterp: material_uimaterial_ui package in flutter/packagesteam-text-inputOwned by Text Input team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions