-
Notifications
You must be signed in to change notification settings - Fork 29.4k
Description
Steps to reproduce
When using different fontSize values for style and placeholderStyle in CupertinoTextField,
the rendered text appears visually lower (not centered) even though textAlignVertical is set to TextAlignVertical.center.
This issue occurs since Flutter 3.35.x, after PR #166952 introduced _BaselineAlignedStack for baseline alignment between placeholder and editable text.
The new baseline-based layout causes the entire text area to appear visually shifted down when the two font sizes differ.
- Create a simple CupertinoTextField with different font sizes for text and placeholder:
CupertinoTextField(
style: const TextStyle(fontSize: 20, height: 1.4),
placeholder: 'Enter text',
placeholderStyle: const TextStyle(fontSize: 16, height: 1.4, color: CupertinoColors.systemGrey),
textAlignVertical: TextAlignVertical.center,
)
- Run on iOS simulator (or macOS with Cupertino style).
- Observe that the text is rendered slightly below the visual center of the input box.
Expected results
The text (and placeholder) should appear visually centered within the field when textAlignVertical is center, regardless of font size differences.
Actual results
The text is baseline-aligned, making smaller placeholder fonts appear too low, and larger text fonts look offset downward relative to the center.
Code sample
Code sample
CupertinoTextField(
style: const TextStyle(fontSize: 20, height: 1.4),
placeholder: 'Enter text',
placeholderStyle: const TextStyle(fontSize: 16, height: 1.4, color: CupertinoColors.systemGrey),
textAlignVertical: TextAlignVertical.center,
)
Screenshots or Video
Screenshots / Video demonstration
[Upload media here]
Logs
Logs
[Paste your logs here]
Flutter Doctor output
Doctor output
[✓] Flutter (Channel stable, 3.35.5, on macOS 26.0 25A354 darwin-arm64, locale zh-Hans-CN) [393ms]
• Flutter version 3.35.5 on channel stable at /Users/liwenhui/.fvm/versions/3.35.5
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision ac4e799d23 (13 days ago), 2025-09-26 12:05:09 -0700
• Engine revision d3d45dcf25
• Dart version 3.9.2
• DevTools version 2.48.0
• Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations,
enable-lldb-debugging
[✓] Android toolchain - develop for Android devices (Android SDK version 36.1.0) [2.2s]
• Android SDK at /Users/liwenhui/Library/Android/sdk
• Emulator version 36.2.11.0 (build_id 14212360) (CL:N/A)
• Platform android-36, build-tools 36.1.0
• ANDROID_HOME = /Users/liwenhui/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
This is the JDK bundled with the latest Android Studio installation on this machine.
To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
• Java version OpenJDK Runtime Environment (build 21.0.8+-14018985-b1038.68)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 26.0.1) [910ms]
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 17A400
• CocoaPods version 1.16.2
[✓] Chrome - develop for the web [73ms]
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2025.1) [72ms]
• 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 21.0.8+-14018985-b1038.68)
[✓] IntelliJ IDEA Ultimate Edition (version 2025.1) [72ms]
• IntelliJ at /Applications/IntelliJ IDEA.app
• Flutter plugin version 85.2.4
• Dart plugin version 251.25267.1
[✓] VS Code (version 1.101.2) [5ms]
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension can be installed from:
🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[✓] Connected device (0 available) [0.2s]
[✓] Network resources [6.0s]
• All expected network resources are available.
• No issues found!