-
Notifications
You must be signed in to change notification settings - Fork 26.7k
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
Unexpected new line added after pressed Enter when using multi-line TextField with TextInputAction.send #125879
Comments
I found a workaround by not using onChanged: (text) {
if (text.isEmpty) {
return;
}
if (!text.endsWith('\n')) {
return;
}
_handleSubmitted(text.trim());
}, But it doesn't work if users want to add one or more new lines at the end. |
I can reproduce the issue using the code sample provided above only on macOs. I tested on chrome, android, iOS & macOS. logsiOS logs
macOS
chrome
flutter doctor -v
|
windows has the same problem. |
This happens on windows & linux as well. Removing flutter doctor -v Linux (stable & master)[!] Flutter (Channel stable, 3.7.12, on Ubuntu 22.04.1 LTS 5.19.0-38-generic, locale en_US.UTF-8)
• Flutter version 3.7.12 on channel stable at /home/huynq/Documents/Working/flutter
! Warning: `dart` on your path resolves to /usr/lib/dart/bin/dart, which is not inside your current Flutter SDK checkout at /home/huynq/Documents/Working/flutter. Consider adding /home/huynq/Documents/Working/flutter/bin to the front of your path.
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 4d9e56e694 (6 days ago), 2023-04-17 21:47:46 -0400
• Engine revision 1a65d409c7
• Dart version 2.19.6
• DevTools version 2.20.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 32.1.0-rc1)
• Android SDK at /home/huynq/Android/Sdk
• Platform android-33, build-tools 32.1.0-rc1
• Java binary at: /home/huynq/Documents/android-studio/jre/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822)
• All Android licenses accepted.
[✓] Chrome - develop for the web
• Chrome at google-chrome
[✓] Linux toolchain - develop for Linux desktop
• clang version 10.0.0-4ubuntu1
• cmake version 3.22.1
• ninja version 1.10.1
• pkg-config version 0.29.2
[✓] Android Studio (version 2021.1)
• Android Studio at /home/huynq/Documents/android-studio
• Flutter plugin version 67.0.1
• Dart plugin version 211.7817
• Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822)
[✓] VS Code (version 1.71.0)
• VS Code at /usr/share/code
• Flutter extension version 3.60.0
[✓] Connected device (2 available)
• Linux (desktop) • linux • linux-x64 • Ubuntu 22.04.1 LTS 5.19.0-38-generic
• Chrome (web) • chrome • web-javascript • Google Chrome 112.0.5615.121
[✓] HTTP Host Availability
• All required HTTP hosts are available
! Doctor found issues in 1 category. [!] Flutter (Channel master, 3.10.0-15.0.pre.28, on Ubuntu 22.04.1 LTS 5.19.0-38-generic, locale en_US.UTF-8)
• Flutter version 3.10.0-15.0.pre.28 on channel master at /home/huynq/Documents/Working/flutter_master
! Warning: `flutter` on your path resolves to /home/huynq/Documents/Working/flutter/bin/flutter, which is not inside your current Flutter SDK checkout at /home/huynq/Documents/Working/flutter_master. Consider adding /home/huynq/Documents/Working/flutter_master/bin to the front of your path.
! Warning: `dart` on your path resolves to /usr/lib/dart/bin/dart, which is not inside your current Flutter SDK checkout at /home/huynq/Documents/Working/flutter_master. Consider adding /home/huynq/Documents/Working/flutter_master/bin to the front of your path.
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 4dbeb3fb06 (7 minutes ago), 2023-04-27 11:19:34 -0400
• Engine revision 381f714972
• Dart version 3.1.0 (build 3.1.0-49.0.dev)
• 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 32.1.0-rc1)
• Android SDK at /home/huynq/Android/Sdk
• Platform android-33, build-tools 32.1.0-rc1
• Java binary at: /home/huynq/Documents/android-studio/jre/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822)
• All Android licenses accepted.
[✓] Chrome - develop for the web
• Chrome at google-chrome
[✓] Linux toolchain - develop for Linux desktop
• clang version 10.0.0-4ubuntu1
• cmake version 3.22.1
• ninja version 1.10.1
• pkg-config version 0.29.2
[✓] Android Studio (version 2021.1)
• Android Studio at /home/huynq/Documents/android-studio
• Flutter plugin version 67.0.1
• Dart plugin version 211.7817
• Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822)
[✓] VS Code (version 1.71.0)
• VS Code at /usr/share/code
• Flutter extension version 3.60.0
[✓] Connected device (2 available)
• Linux (desktop) • linux • linux-x64 • Ubuntu 22.04.1 LTS 5.19.0-38-generic
• Chrome (web) • chrome • web-javascript • Google Chrome 112.0.5615.121
[✓] Network resources
• All expected network resources are available.
! Doctor found issues in 1 category. flutter doctor -v windows (stable & master) ```bash [√] Flutter (Channel stable, 3.7.12, on Microsoft Windows [Version 10.0.19045.2846], locale en-US) • Flutter version 3.7.12 on channel stable at C:\WIP\flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 4d9e56e (6 days ago), 2023-04-17 21:47:46 -0400 • Engine revision 1a65d409c7 • Dart version 2.19.6 • DevTools version 2.20.1 [√] Windows Version (Installed version of Windows is version 10 or higher) [√] Android toolchain - develop for Android devices (Android SDK version 33.0.0) • Android SDK at C:\AndroidSDK • Platform android-33, build-tools 33.0.0 • ANDROID_HOME = C:\AndroidSDK • Java binary at: C:\Program Files\Android\Android Studio Electric Eel 2022.1.1\jbr\bin\java • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866) • All Android licenses accepted. [√] Chrome - develop for the web • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe [√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.4.4) • Visual Studio at D:\DOWNLOADWORK\VS2022 • Visual Studio Community 2022 version 17.4.33213.308 • Windows 10 SDK version 10.0.19041.0 [√] Android Studio (version 2021.2) • Android Studio at C:\Program Files\Android\Android Studio • 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 11.0.12+7-b1504.28-7817840) [√] Android Studio (version 2022.1) • Android Studio at C:\Program Files\Android\Android Studio Electric Eel 2022.1.1 • 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 11.0.13+0-b1751.21-8125866) [√] VS Code (version 1.77.3) • VS Code at C:\Users\ADMIN\AppData\Local\Programs\Microsoft VS Code • Flutter extension version 3.62.0 [√] Connected device (3 available) • Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.19045.2846] • Chrome (web) • chrome • web-javascript • Google Chrome 112.0.5615.138 • Edge (web) • edge • web-javascript • Microsoft Edge 111.0.1661.54 [√] HTTP Host Availability • All required HTTP hosts are available • No issues found! ``` ```bash [!] Flutter (Channel master, 3.10.0-12.0.pre.29, on Microsoft Windows [Version 10.0.19045.2846], locale en-US) • Flutter version 3.10.0-12.0.pre.29 on channel master at C:\WIP\flutter_master ! Warning: `flutter` on your path resolves to C:\WIP\flutter\bin\flutter, which is not inside your current Flutter SDK checkout at C:\WIP\flutter_master. Consider adding C:\WIP\flutter_master\bin to the front of your path. ! Warning: `dart` on your path resolves to C:\WIP\flutter\bin\dart, which is not inside your current Flutter SDK checkout at C:\WIP\flutter_master. Consider adding C:\WIP\flutter_master\bin to the front of your path. • Upstream repository https://github.com/flutter/flutter.git • Framework revision 60077ff (16 hours ago), 2023-04-23 07:09:16 -0400 • Engine revision fcf46af2d3 • Dart version 3.1.0 (build 3.1.0-35.0.dev) • 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. [√] Windows Version (Installed version of Windows is version 10 or higher) [√] Android toolchain - develop for Android devices (Android SDK version 33.0.0) • Android SDK at C:\AndroidSDK • Platform android-33, build-tools 33.0.0 • ANDROID_HOME = C:\AndroidSDK • Java binary at: C:\Program Files\Android\Android Studio Electric Eel 2022.1.1\jbr\bin\java • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866) • All Android licenses accepted. [√] Chrome - develop for the web • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe [√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.4.4) • Visual Studio at D:\DOWNLOADWORK\VS2022 • Visual Studio Community 2022 version 17.4.33213.308 • Windows 10 SDK version 10.0.19041.0 [√] Android Studio (version 2021.2) • Android Studio at C:\Program Files\Android\Android Studio • 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 11.0.12+7-b1504.28-7817840) [√] Android Studio (version 2022.1) • Android Studio at C:\Program Files\Android\Android Studio Electric Eel 2022.1.1 • 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 11.0.13+0-b1751.21-8125866) [√] VS Code (version 1.77.3) • VS Code at C:\Users\ADMIN\AppData\Local\Programs\Microsoft VS Code • Flutter extension version 3.62.0 [√] Connected device (3 available) • Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.19045.2846] • Chrome (web) • chrome • web-javascript • Google Chrome 112.0.5615.138 • Edge (web) • edge • web-javascript • Microsoft Edge 111.0.1661.54 [√] Network resources • All expected network resources are available. ! Doctor found issues in 1 category. ``` |
I checked on the linux engine, this is the code which adds the new line before performing the action: This code does not check if the action is something else than Fixing this at the framework level is possible, but it might be somewhat hacky because the framework would have to remove the @justinmc I'm very interested to get your feedback on whether this should be fix at the framework or engine level? |
This should be fixed in the engine. We don't want to introduce more complexity in the framework code, and some embedders might not need the same treatment. cc @cbracken |
…#41977) ## Description This PR updates the macOS text input plugin to avoid adding a new line on a multiline text field when action is not set to `TextInputAction.newline`. ## Related Issue macOS implementation for flutter/flutter#125879. (similar to the Linux implementation in #41895). ## Tests Adds 2 tests.
@bleroux thank you for addressing this issue. 🔥 |
…ne (#42244) ## Description This PR updates the Windows text input plugin to avoid adding a new line on a multiline text field when action is not set to `TextInputAction.newline`. ## Related Issue Fixes flutter/flutter#125879 as Linux and macOS implementations are merged. Linux PR: #41895 macOS PR: #41977 ## Tests Adds 2 tests.
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 |
Is there an existing issue for this?
Steps to reproduce
(Or setup a
TextField
withtextInputAction: TextInputAction.send
and multi-line enabled)Expected results
onSubmitted
oronEditingCompleted
is called with no newline (\n
) added at the cursor's current position.Actual results
New line is added before
onSubmitted
oronEditingCompleted
is called.Code sample
Code sample
Screenshots or Video
Screenshots / Video demonstration
Flutter Doctor output
Doctor output
The text was updated successfully, but these errors were encountered: