Closed theodelrieu closed 2 days ago
Thanks for the report. I'm also able to see the issue. The current workaround is to apply the same text style for labelStyle
:
labelStyle: Theme.of(context).textTheme.labelLarge!,
floatingLabelStyle: Theme.of(context).textTheme.labelLarge!,
@huycozy My OP might have been a bit unclear, as the video shows the main issue but not the very small bump I mentioned here:
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.
Here is a second video to show this behavior:
https://github.com/flutter/flutter/assets/15652306/1baa035d-256b-4b66-8145-47faedc193b5
@theodelrieu Thanks for the detailed report.
I agree that having floatingLabelStyle
always applied when floatingLabelBehavior
is FloatingLabelBehavior.always
makes sense.
About the small animation you pointed in https://github.com/flutter/flutter/issues/147231#issuecomment-2074289842. I can't reproduce it using the following example:
Can you try this code sample and see if you still get this animation? If not can you point out the difference with your own repro?
@bleroux
Hello, I think I reproduced the issue with your code sample:
https://github.com/flutter/flutter/assets/15652306/19b979db-e947-4fe1-a6b7-fcc82c9720e0
It might be an iOS-specific issue? I'm on macOS Sonoma (14.2.1), on a M1 chip.
Thanks for the recording. :pray: I can reproduce on iOS and Flutter 3.19.6 but not on master channel. The small animation was fixed in https://github.com/flutter/flutter/pull/141943.
I will fill a PR to make floatingLabelStyle
always applied when floatingLabelBehavior
is FloatingLabelBehavior.always
.
@bleroux Thanks, apparently the animation fix was merged on Jan 24, how comes I still have the issue on the stable channel?
Here's my flutter --version
output:
Flutter 3.19.6 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 54e66469a9 (8 days ago) • 2024-04-17 13:08:03 -0700
Engine • revision c4cd48e186
Tools • Dart 3.3.4 • DevTools 2.31.1
@theodelrieu That's because this commit landed after the 3.19 version was forked from master (3.19 was released on February 15, but the corresponding branch did not pulled master changes after the first week of January, except some cherry-picks). This fix will be part of next stable release (there is usually 3 months between stable releases).
This wiki page explains how to find out which releases contain a particular commit. In this case, we can see that it was not included in 3.19 stable release.
Another interesting page is the 3.19 changelog where one can see all the commits that were part of the stable release: https://docs.flutter.dev/release/release-notes/release-notes-3.19.0
Oh of course, thanks for the explanation!
Steps to reproduce
Hello,
I've been trying to force my TextField to always use a floating label, by setting
InputDecoration
'sfloatingLabelBehavior
toFloatingLabelBehavior.always
.However, when the field is not focused, or is empty,
labelStyle
is used. By digging through the code, I found this line inInputDecorator
.Looking at the definition of
_labelShouldWithdraw
explains why I get this behavior. I then tried to set the same style for bothlabelStyle
andfloatingLabelStyle
, 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 theTextField
was. Have I missed something?Expected results
The label always stays in place, only applying
floatingLabelStyle
.Actual results
The label alternates between
floatingLabelStyle
andlabelStyle
, even thoughFloatingLabelBehavior.always
is used.Code sample
Code sample
```dart TextField( decoration: InputDecoration( floatingLabelBehavior: FloatingLabelBehavior.always, labelText: "label", floatingLabelStyle: Theme.of(context).textTheme.labelLarge!, ) ) ```Screenshots or Video
Screenshots / Video demonstration
https://github.com/flutter/flutter/assets/15652306/a2e8d32d-cfb4-4f36-b94f-839cfab2c40cLogs
Logs
```console [Paste your logs here] ```Flutter Doctor output
Doctor output
```console [✓] 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. ```