Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TextField widget hint text is not vertically aligned #40248

Closed
virskor opened this issue Sep 11, 2019 · 17 comments
Closed

TextField widget hint text is not vertically aligned #40248

virskor opened this issue Sep 11, 2019 · 17 comments
Labels
f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.

Comments

@virskor
Copy link

virskor commented Sep 11, 2019

Details

I am using Flutter TextField widget, and i found that hint text is not automatically vertically aligned.

I found no methods to modify hint text Align.
look at this picture.

2019-09-11 20 20 19

I found many people troubled by this problem, and i had try my best to find out reason why??

I FOUND THAT, DUDE.

Using theme data widget to modify app fonts, like Chinese font on IOS named PingFang SC.
After remove any fonts setting, you see this widget rendered perfect.
2019-09-11 20 20 32

Hope any method to modify hint text align.
Thanks ,Dude i know that you are working hard to make Flutter better, and i am grateful to you for your help.

Logs

[✓] Flutter (Channel dev, v1.10.1, on Mac OS X 10.14.6 18G95, locale zh-Hans-CN)
• Flutter version 1.10.1 at /Users/weizhang/flutter
• Framework revision ce45c2d (5 天前), 2019-09-06 20:11:41 -0400
• Engine revision b9ce250
• Dart version 2.5.0 (build 2.5.0-dev.4.0 be66176534)

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at /Users/weizhang/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 29.0.2
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 10.3)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 10.3, Build version 10G8
• CocoaPods version 1.7.5

[✓] Android Studio (version 3.5)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 39.0.3
• Dart plugin version 191.8423
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

[✓] VS Code (version 1.38.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.4.1

[✓] Connected device (1 available)
• iPhone Xs Max • 2FF110A8-4E4F-42EA-99D5-918CEF5422C3 • ios • com.apple.CoreSimulator.SimRuntime.iOS-12-4 (simulator)

@virskor virskor added the c: performance Relates to speed or footprint issues (see "perf:" labels) label Sep 11, 2019
@HansMuller HansMuller added f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. and removed c: performance Relates to speed or footprint issues (see "perf:" labels) labels Sep 11, 2019
@jp1017
Copy link

jp1017 commented Sep 12, 2019

Same issue with

Flutter 1.9.1+hotfix.2 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 2d2a1ff (5 days ago) • 2019-09-06 18:39:49 -0700
Engine • revision b863200
Tools • Dart 2.5.0

@baoxiehao
Copy link

Same problem with v1.9.1+hotfix.2.
And it seems not 100% reproducible for every device.

@heyman0823
Copy link

Maybe you can hack as follows before this bug fixed:

Localizations(
      locale: Locale("en", ""),
      delegates: [
        GlobalMaterialLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate,
      ],
      child: TextFormField(...)
)

@virskor
Copy link
Author

virskor commented Sep 16, 2019

@heyman0823 this will make cutButtonLabel not automatically show Chinese or etc....

@heyman0823
Copy link

@virskor You can wrap TextFormField with a custom widget, and pass the localized string(label, hint) by constructor:

class InputWidget extends StatefulWidget {
  final String labelText;

  const InputWidget({
    this.labelText,
  });

  @override
  Widget build(BuildContext context) {
    return Localizations(
      locale: Locale("en", ""),
      delegates: [
        GlobalMaterialLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate,
      ],
      child: TextFormField(
        ...
        decoration: InputDecoration(
          labelText: widget.labelText,
          ...
        ),
      );
    );
  }
}

@chenenyu
Copy link

+1

1 similar comment
@mainxml
Copy link

mainxml commented Sep 18, 2019

+1

@githubhai
Copy link

试试 TextField > style > textBaseline: TextBaseline.alphabetic

@jp1017
Copy link

jp1017 commented Sep 27, 2019

试试 TextField > style > textBaseline: TextBaseline.alphabetic

Good, 全局修改的话,设置主题即可:

ThemeData(
    textTheme: TextTheme(subhead: TextStyle(textBaseline: TextBaseline.alphabetic)),

@heibaikn
Copy link

试试 TextField > style > textBaseline: TextBaseline.alphabetic

Good, 全局修改的话,设置主题即可:

ThemeData(
    textTheme: TextTheme(subhead: TextStyle(textBaseline: TextBaseline.alphabetic)),

谢谢 very much.

child: TextField(
    style: TextStyle(textBaseline: TextBaseline.alphabetic),
)

@phoenixsky
Copy link

试试 TextField > style > textBaseline: TextBaseline.alphabetic

Good, 全局修改的话,设置主题即可:

ThemeData(
    textTheme: TextTheme(subhead: TextStyle(textBaseline: TextBaseline.alphabetic)),

use TextTheme()
it would change BottomNavigationBarItem icon color to black on iOS DarkMode
I recommend that

 textTheme: theme.textTheme.copyWith(
          subhead: theme.textTheme.subhead
              .copyWith(textBaseline: TextBaseline.alphabetic)),

@iapicca
Copy link
Contributor

iapicca commented Oct 25, 2019

Hi @virskor
I see there's an open issue addressing the case you described.
Please follow up on that issue,
I'm closing the current one as duplicate.
If you disagree please write in the comments
and I will reopen it.
Thank you

@iapicca iapicca closed this as completed Oct 25, 2019
@GaryQian
Copy link
Contributor

GaryQian commented Nov 6, 2019

This should be fixed by #44029

@Rempage
Copy link

Rempage commented Feb 28, 2020

you can set TextField->hintStyle->height:1.0

@1111mp
Copy link

1111mp commented Jun 30, 2020

The CupertinoTextField has the same problem.
cant resolve it.

@snehal741
Copy link

Put it inside a container
Worked for me!
Container( child: TextFormField( ) )

@github-actions
Copy link

github-actions bot commented Aug 8, 2021

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
Development

No branches or pull requests