-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
Steps to reproduce
Hello,
I've been trying to force my TextField to always use a floating label, by setting InputDecoration's floatingLabelBehavior to FloatingLabelBehavior.always.
However, when the field is not focused, or is empty, labelStyle is used.
By digging through the code, I found this line in InputDecorator.
Looking at the definition of _labelShouldWithdraw explains why I get this behavior. I then tried to set the same style for both labelStyle and floatingLabelStyle, but there is a very small animation when I focus/unfocus the text field.
By using FloatingLabelBehavior.always, I expected the label to stick to its position no matter in which state the TextField was.
Have I missed something?
Expected results
The label always stays in place, only applying floatingLabelStyle.
Actual results
The label alternates between floatingLabelStyle and labelStyle, even though FloatingLabelBehavior.always is used.
Code sample
Code sample
TextField(
decoration: InputDecoration(
floatingLabelBehavior: FloatingLabelBehavior.always,
labelText: "label",
floatingLabelStyle: Theme.of(context).textTheme.labelLarge!,
)
)Screenshots or Video
Screenshots / Video demonstration
Screen.Recording.2024-04-23.at.13.53.40.mov
Logs
Logs
[Paste your logs here]Flutter Doctor output
Doctor output
[✓] Flutter (Channel stable, 3.19.6, on macOS 14.2.1 23C71 darwin-arm64, locale en-FR)
• Flutter version 3.19.6 on channel stable at /Users/theo/.local/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 54e66469a9 (6 days ago), 2024-04-17 13:08:03 -0700
• Engine revision c4cd48e186
• Dart version 3.3.4
• DevTools version 2.31.1
[!] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
• Android SDK at /Users/theo/Library/Android/sdk
• Platform android-34, build-tools 33.0.0
• ANDROID_HOME = /Users/theo/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses
[✓] Xcode - develop for iOS and macOS (Xcode 15.3)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 15E204a
• CocoaPods version 1.13.0
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2022.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 17.0.6+0-17.0.6b802.4-9586694)
[✓] Connected device (3 available)
• iPhone 15 (mobile) • BCE05AEF-41E7-48DF-BE31-969DE94790C4 • ios • com.apple.CoreSimulator.SimRuntime.iOS-17-0 (simulator)
• macOS (desktop) • macos • darwin-arm64 • macOS 14.2.1 23C71 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 124.0.6367.62
[✓] Network resources
• All expected network resources are available.
! Doctor found issues in 1 category.Metadata
Metadata
Assignees
Labels
Type
Projects
Status