Skip to content

Material InputDecoration contentPadding is broken in RTL #129591

Closed

Description

@Caffeinix

Is there an existing issue for this?

Steps to reproduce

  1. Create a TextField with an InputDecoration that uses an EdgeInsetsDirectional for its contentPadding property that specifies a non-zero value for end.
  2. Set the directionality of the app to TextDirection.rtl.

Expected results

The contentPadding property should be applied the same way it is in LTR, except the left and right edges should be flipped.

Actual results

The contentPadding property appears to override some default padding in InputDecorator, causing the leading icon to be rendered outside of the field's bounding box.

Code sample

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

/// Flutter code sample for [InputDecoration].

void main() => runApp(const InputDecorationExampleApp());

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('InputDecoration Sample')),
        body: const Padding(
          padding: EdgeInsets.all(8),
          child: Column(
            children: [
              InputDecorationExample(),
              SizedBox(height: 8),
              Directionality(
                textDirection: TextDirection.rtl,
                child: InputDecorationExample(),
              ),
            ],
          ),
        ),
      ),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    return const TextField(
      decoration: InputDecoration(
        // This line causes the bug.
        contentPadding: EdgeInsetsDirectional.only(end: 24),
        enabledBorder: OutlineInputBorder(),
        disabledBorder: OutlineInputBorder(),
        focusedBorder: OutlineInputBorder(),
        filled: true,
        hintText: 'Search',
        isDense: true,
        prefixIcon: Focus(child: Icon(Icons.search)),
        suffixIcon: Icon(Icons.send),
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration

Screenshot 2023-06-26 at 6 36 21 PM

Logs

Logs

No console log messages are observed.

Flutter Doctor output

Doctor output

N/A (this can be reproduced in DartPad).

Activity

  1. danagbemava-nc commented on Jun 27, 2023

    @danagbemava-nc
    Member

    Reproducible using the code sample provided above.

    flutter doctor -v
    [!] Flutter (Channel stable, 3.10.5, on macOS 13.4.1 22F82 darwin-arm64, locale en-GB)
        • Flutter version 3.10.5 on channel stable at /Users/nexus/dev/sdks/flutter
        ! Warning: `flutter` on your path resolves to /Users/nexus/dev/sdks/flutters/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/nexus/dev/sdks/flutter. Consider adding /Users/nexus/dev/sdks/flutter/bin to the front of your path.
        ! Warning: `dart` on your path resolves to /Users/nexus/dev/sdks/flutters/bin/dart, which is not inside your current Flutter SDK checkout at /Users/nexus/dev/sdks/flutter. Consider adding /Users/nexus/dev/sdks/flutter/bin to the front of your path.
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 796c8ef792 (13 days ago), 2023-06-13 15:51:02 -0700
        • Engine revision 45f6e00911
        • Dart version 3.0.5
        • DevTools version 2.23.1
        • 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)
        • Android SDK at /Users/nexus/Library/Android/sdk
        • Platform android-33, build-tools 33.0.0
        • Java binary at: /Users/nexus/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/222.4459.24.2221.9971841/Android Studio.app/Contents/jbr/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 14.3)
        • Xcode at /Applications/Xcode-14.3.0.app/Contents/Developer
        • Build 14E222b
        • CocoaPods version 1.12.1
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2022.2)
        • Android Studio at /Users/nexus/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/222.4459.24.2221.9971841/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 17.0.6+0-17.0.6b802.4-9586694)
    
    [✓] Android Studio (version 2022.2)
        • Android Studio at /Users/nexus/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/222.4459.24.2221.10121639/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 17.0.6+0-17.0.6b802.4-9586694)
    
    [✓] IntelliJ IDEA Ultimate Edition (version 2023.1.3)
        • IntelliJ at /Users/nexus/Applications/JetBrains Toolbox/IntelliJ IDEA Ultimate.app
        • Flutter plugin version 74.0.4
        • Dart plugin version 231.9161.14
    
    [✓] IntelliJ IDEA Ultimate Edition (version 2023.1.2)
        • IntelliJ at /Users/nexus/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/231.9011.34/IntelliJ IDEA.app
        • 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
    
    [✓] IntelliJ IDEA Ultimate Edition (version 2023.1.3)
        • IntelliJ at /Users/nexus/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/231.9161.38/IntelliJ IDEA.app
        • 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
    
    [✓] VS Code (version 1.79.2)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.66.0
    
    [✓] Connected device (4 available)
        • Pixel 7 (mobile) • adb-28291FDH2001SA-5Lv71w._adb-tls-connect._tcp. • android-arm64  • Android 13 (API 33)
        • Nexus (mobile)   • 00008020-001875E83A38002E                        • ios            • iOS 16.5.1 20F75
        • macOS (desktop)  • macos                                            • darwin-arm64   • macOS 13.4.1 22F82 darwin-arm64
        • Chrome (web)     • chrome                                           • web-javascript • Google Chrome 114.0.5735.133
        ! Error: Nexus is busy: Waiting to connect and unlock the device. Xcode will continue when Nexus is finished. (code -10)
    
    [✓] Network resources
        • All expected network resources are available.
    
    ! Doctor found issues in 1 category.
    
    [✓] Flutter (Channel master, 3.12.0-11.0.pre.32, on macOS 13.4.1 22F82 darwin-arm64, locale en-GB)
        • Flutter version 3.12.0-11.0.pre.32 on channel master at /Users/nexus/dev/sdks/flutters
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 7dbdacff46 (8 hours ago), 2023-06-26 22:05:23 -0400
        • Engine revision f320b8c36f
        • Dart version 3.1.0 (build 3.1.0-246.0.dev)
        • DevTools version 2.24.0
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
        • Android SDK at /Users/nexus/Library/Android/sdk
        • Platform android-33, build-tools 33.0.0
        • Java binary at: /Users/nexus/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/222.4459.24.2221.9971841/Android Studio.app/Contents/jbr/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 14.3)
        • Xcode at /Applications/Xcode-14.3.0.app/Contents/Developer
        • Build 14E222b
        • CocoaPods version 1.12.1
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2022.2)
        • Android Studio at /Users/nexus/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/222.4459.24.2221.9971841/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 17.0.6+0-17.0.6b802.4-9586694)
    
    [✓] Android Studio (version 2022.2)
        • Android Studio at /Users/nexus/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/222.4459.24.2221.10121639/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 17.0.6+0-17.0.6b802.4-9586694)
    
    [✓] IntelliJ IDEA Ultimate Edition (version 2023.1.3)
        • IntelliJ at /Users/nexus/Applications/JetBrains Toolbox/IntelliJ IDEA Ultimate.app
        • Flutter plugin version 74.0.4
        • Dart plugin version 231.9161.14
    
    [✓] IntelliJ IDEA Ultimate Edition (version 2023.1.2)
        • IntelliJ at /Users/nexus/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/231.9011.34/IntelliJ IDEA.app
        • 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
    
    [✓] IntelliJ IDEA Ultimate Edition (version 2023.1.3)
        • IntelliJ at /Users/nexus/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/231.9161.38/IntelliJ IDEA.app
        • 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
    
    [✓] VS Code (version 1.79.2)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.66.0
    
    [✓] Connected device (4 available)
        • Pixel 7 (mobile) • adb-28291FDH2001SA-5Lv71w._adb-tls-connect._tcp. • android-arm64  • Android 13 (API 33)
        • Nexus (mobile)   • 00008020-001875E83A38002E                        • ios            • iOS 16.5.1 20F75
        • macOS (desktop)  • macos                                            • darwin-arm64   • macOS 13.4.1 22F82 darwin-arm64
        • Chrome (web)     • chrome                                           • web-javascript • Google Chrome 114.0.5735.133
    
    [✓] Network resources
        • All expected network resources are available.
    
    • No issues found!
    
  2. added
    a: text inputEntering text in a text field or keyboard related problems
    frameworkflutter/packages/flutter repository. See also f: labels.
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    a: internationalizationSupporting other languages or locales. (aka i18n)
    and removed
    in triagePresently being triaged by the triage team
    on Jun 27, 2023
  3. goderbauer commented on Jun 27, 2023

    @goderbauer
    Member

    @justinmc A g3 customer is experiencing this issue. Any change somebody from the "text input" world could take a look?

  4. self-assigned this
    on Jun 27, 2023
  5. justinmc commented on Jun 27, 2023

    @justinmc
    Contributor

    InputDecorator is getting tricky to make changes to, but in this case I think this is strictly buggy behavior and we can fix it. I'm taking a look.

  6. github-actions commented on Jul 13, 2023

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

  7. locked as resolved and limited conversation to collaborators on Jul 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

a: internationalizationSupporting other languages or locales. (aka i18n)a: text inputEntering text in a text field or keyboard related problemscustomer: quake (g3)found in release: 3.10Found to occur in 3.10found in release: 3.12Found to occur in 3.12frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: material_uimaterial_ui package in flutter/packagesr: fixedIssue is closed as already fixed in a newer version

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions