Skip to content

Textfield cursor height strange behaviour(gif) #64072

Closed

Description

@vasilich6107

Relates to #61714

@guidezpl @justinmc

Steps to Reproduce

import 'package:flutter/material.dart';

class Pr61714CursorHeight extends StatefulWidget {
  @override
  _Pr61714CursorHeightState createState() => _Pr61714CursorHeightState();
}

class _Pr61714CursorHeightState extends State<Pr61714CursorHeight> {
  double height = 5;

  double width = 2;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Label unnecessarily elided'),
      ),
      body: Column(
        children: [
          Padding(
            padding: const EdgeInsets.all(8.0),
            child: TextField(
              cursorHeight: height,
              cursorWidth: width,
            ),
          ),
          Slider(
            value: height,
            min: 5,
            max: 50.0,
            divisions: 15,
            activeColor: Colors.red,
            inactiveColor: Colors.black,
            label: '$height',
            onChanged: (double newValue) {
              setState(() {
                height = newValue;
              });
            },
            semanticFormatterCallback: (double newValue) {
              return '$newValue';
            },
          ),
          Slider(
            value: width,
            min: 2,
            max: 20.0,
            divisions: 9,
            activeColor: Colors.red,
            inactiveColor: Colors.black,
            label: '$width',
            onChanged: (double newValue) {
              setState(() {
                width = newValue;
              });
            },
            semanticFormatterCallback: (double newValue) {
              return '$newValue';
            },
          ),
        ],
      ),
    );
  }
}

Expected results:
Consistent behaviour while changing the cursor height on the fly

Actual results:
Cursor jumps and cropped. See the attached gif

Logs
Analyzing whatsup_flutter...                                    

   info • Unused import: 'package:whatsup_flutter/whats_up.dart' • lib/home_screen.dart:6:8 • unused_import
   info • The value of the field '_search' isn't used • lib/home_screen.dart:14:10 • unused_field
   info • The declaration '_handleSearchClear' isn't referenced • lib/home_screen.dart:28:8 • unused_element
   info • Don't explicitly initialize variables to null • lib/text.dart:142:7 • avoid_init_to_null

[✓] Flutter (Channel master, 1.21.0-10.0.pre.139, on Mac OS X 10.15.4 19E287, locale en-UA)
    • Flutter version 1.21.0-10.0.pre.139 at /Users/vasilich/IdeaProjects/flutter
    • Framework revision a51dc3d913 (12 hours ago), 2020-08-18 02:51:02 -0400
    • Engine revision 0b330467da
    • Dart version 2.10.0 (build 2.10.0-38.0.dev)

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at /Users/vasilich/Library/Android/sdk
    • Platform android-29, build-tools 29.0.2
    • ANDROID_HOME = /Users/vasilich/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.6)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.6, Build version 11E708
    • CocoaPods version 1.9.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[!] Android Studio
    • Android Studio at /Applications/Android Studio 4.1 Preview.app/Contents
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

[✓] Android Studio (version 4.0)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 48.1.2
    • Dart plugin version 193.7361
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

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

[✓] Connected device (4 available)
    • iPhone 11 Pro (mobile) • 34A1C1C6-659A-4332-A240-988ABC68E2FF • ios            • com.apple.CoreSimulator.SimRuntime.iOS-13-6 (simulator)
    • macOS (desktop)        • macos                                • darwin-x64     • Mac OS X 10.15.4 19E287
    • Web Server (web)       • web-server                           • web-javascript • Flutter Tools
    • Chrome (web)           • chrome                               • web-javascript • Google Chrome 84.0.4147.125

! Doctor found issues in 1 category.

Activity

  1. justinmc commented on Aug 18, 2020

    @justinmc
    Contributor

    @vasilich6107 Thanks for opening this, I'm trying to reproduce it. Can you update your example so that it doesn't use the whatsup_flutter package?

  2. vasilich6107 commented on Aug 19, 2020

    @vasilich6107
    ContributorAuthor

    @justinmc - done.
    Thanks for quick response.

  3. guidezpl commented on Aug 19, 2020

    @guidezpl
    Member

    Reproed. I noticed that when you type a letter, the cursor adjusts back to the expected size, and stays correct

  4. pedromassangocode commented on Aug 19, 2020

    @pedromassangocode

    I was able to reproduce this on latest master channel.

    Worth noting that the size of the cursor only changes when the field is empty. Not sure if this is the expected behaviour when setting the cursorHeight property and if it is then we probably may need to update the API docs of that property.

    field

    flutter doctor -v
    [✓] Flutter (Channel master, 1.21.0-10.0.pre.138, on Mac OS X 10.15.6 19G2021,
        locale en)
        • Flutter version 1.21.0-10.0.pre.138 at
          /Users/pedromassango/dev/SDKs/flutter_master
        • Framework revision 3562b3c0de (27 hours ago), 2020-08-18 01:46:02 -0400
        • Engine revision 02de4eb7ce
        • Dart version 2.10.0 (build 2.10.0-37.0.dev)
    
     
    [!] Android toolchain - develop for Android devices (Android SDK version 30.0.1)
        • Android SDK at /Users/pedromassango/Library/Android/sdk
        • Platform android-30, build-tools 30.0.1
        • Java binary at: /Applications/Android
          Studio.app/Contents/jre/jdk/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build
          1.8.0_242-release-1644-b3-6222593)
        ! Some Android licenses not accepted.  To resolve this, run: flutter doctor
          --android-licenses
    
    [✓] Xcode - develop for iOS and macOS (Xcode 11.6)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Xcode 11.6, Build version 11E708
        • CocoaPods version 1.9.3
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [!] Android Studio (version 4.0)
        • Android Studio at /Applications/Android Studio.app/Contents
        ✗ Flutter plugin not installed; this adds Flutter specific functionality.
        ✗ Dart plugin not installed; this adds Dart specific functionality.
        • Java version OpenJDK Runtime Environment (build
          1.8.0_242-release-1644-b3-6222593)
    
    [✓] IntelliJ IDEA Community Edition (version 2020.2)
        • IntelliJ at /Applications/IntelliJ IDEA CE.app
        • Flutter plugin version 48.1.4
        • Dart plugin version 202.6397.47
    
    [!] VS Code (version 1.48.0)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        ✗ Flutter extension not installed; install from
          https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
    
    [✓] Connected device (4 available)
        • sdk gphone x86 (mobile) • emulator-5554 • android-x86    • Android 11 (API
          30) (emulator)
        • macOS (desktop)         • macos         • darwin-x64     • Mac OS X
          10.15.6 19G2021
        • Web Server (web)        • web-server    • web-javascript • Flutter Tools
        • Chrome (web)            • chrome        • web-javascript • Google Chrome
          84.0.4147.135
    
    ! Doctor found issues in 3 categories.
    
  5. added
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    a: text inputEntering text in a text field or keyboard related problems
    p: material_uimaterial_ui package in flutter/packages
    frameworkflutter/packages/flutter repository. See also f: labels.
    on Aug 19, 2020
  6. guidezpl commented on Aug 19, 2020

    @guidezpl
    Member

    Interesting, macOS and iOS applied cursor height when the field wasn't empty text, as expected.

  7. pedromassangocode commented on Aug 19, 2020

    @pedromassangocode

    I didn’t noticed that at first. So we just found a new bug. @guidezpl do you think it is necessary to file a new issue? or we can track it here?

  8. guidezpl commented on Aug 19, 2020

    @guidezpl
    Member

    We can track it here

  9. rusticpow commented on Sep 29, 2021

    @rusticpow

    Still repro Flutter 2.5.1

    flutter doctor -v

    [✓] Flutter (Channel stable, 2.5.1, on macOS 11.6 20G165 darwin-arm, locale en-RU)
    • Flutter version 2.5.1 at /Users/rzakirov/Sdk/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision ffb2ece (12 days ago), 2021-09-17 15:26:33 -0400
    • Engine revision b3af521a05
    • Dart version 2.14.2

    [!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /Users/rzakirov/Library/Android/sdk
    ✗ cmdline-tools component is missing
    Run path/to/sdkmanager --install "cmdline-tools;latest"
    See https://developer.android.com/studio/command-line for more details.
    ✗ Android license status unknown.
    Run flutter doctor --android-licenses to accept the SDK licenses.
    See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.

    [✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 13.0, Build version 13A233
    • CocoaPods version 1.10.1

    [✓] Android Studio (version 4.1)
    • 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 1.8.0_242-release-1644-b3-6915495)

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

    [✓] Connected device (2 available)
    • R’s iPhone (mobile) • 00008030-00145506116B802E • ios • iOS 15.0 19A346
    • macOS (desktop) • macos • darwin-arm64 • macOS 11.6 20G165 darwin-arm

    ! Doctor found issues in 1 category.

  10. maheshj01 commented on Dec 21, 2022

    @maheshj01
    Member

    I wonder if this is still valid given that the Textfield loses focus (Cursor goes away) when interacting with other widgets. And when the textfield is focused back it shows the appropriate height.

    The behavior is similar for Desktop

    Screen.Recording.2022-12-20.at.7.12.14.PM.mov
    flutter doctor -v (mac)
    [✓] Flutter (Channel master, 3.7.0-3.0.pre.33, on macOS 12.6 21G115 darwin-arm64, locale en-IN)
        • Flutter version 3.7.0-3.0.pre.33 on channel master 
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 5201856805 (38 minutes ago), 2022-12-05 18:27:21 -0800
        • Engine revision a309d239c4
        • Dart version 2.19.0 (build 2.19.0-463.0.dev)
        • DevTools version 2.20.0
        • 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 33.0.0-rc4)
        • Android SDK at /Users/mahesh/Library/Android/sdk
        • Platform android-33, build-tools 33.0.0-rc4
        • ANDROID_HOME = /Users/mahesh/Library/Android/sdk
        • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 14.0.1)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Build 14A400
        • CocoaPods version 1.11.3
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2021.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 11.0.12+0-b1504.28-7817840)
    
    [✓] IntelliJ IDEA Community Edition (version 2021.2.1)
        • IntelliJ at /Applications/IntelliJ IDEA CE.app
        • Flutter plugin version 61.2.4
        • Dart plugin version 212.5080.8
    
    [✓] VS Code (version 1.70.2)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.55.20221129
    
    [✓] Connected device (3 available)
        • iPhone 12 Pro (mobile) • 026D5789-9E78-4AD5-B1B2-3F8D4E7F65E4 • ios            •
          com.apple.CoreSimulator.SimRuntime.iOS-14-5 (simulator)
        • macOS (desktop)        • macos                                • darwin-arm64   • macOS 12.6 21G115 darwin-arm64
        • Chrome (web)           • chrome                               • web-javascript • Google Chrome 108.0.5359.94
    
    [✓] HTTP Host Availability
        • All required HTTP hosts are available
    
    • No issues found!
    
    [✓] Flutter (Channel stable, 3.3.9, on macOS 12.6 21G115 darwin-arm, locale en-IN)
        • Flutter version 3.3.9 on channel stable at /Users/mahesh/Development/flutter
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision b8f7f1f986 (24 hours ago), 2022-11-23 06:43:51 +0900
        • Engine revision 8f2221fbef
        • Dart version 2.18.5
        • DevTools version 2.15.0
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0-rc4)
        • Android SDK at /Users/mahesh/Library/Android/sdk
        • Platform android-33, build-tools 33.0.0-rc4
        • ANDROID_HOME = /Users/mahesh/Library/Android/sdk
        • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 14.0.1)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Build 14A400
        • CocoaPods version 1.11.3
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2021.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 11.0.12+0-b1504.28-7817840)
    
    [✓] IntelliJ IDEA Community Edition (version 2021.2.1)
        • IntelliJ at /Applications/IntelliJ IDEA CE.app
        • Flutter plugin version 61.2.4
        • Dart plugin version 212.5080.8
    
    [✓] VS Code (version 1.70.2)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.53.20221101
    
    [✓] Connected device (3 available)
        • iPhone 12 Pro (mobile) • 026D5789-9E78-4AD5-B1B2-3F8D4E7F65E4 • ios            •
          com.apple.CoreSimulator.SimRuntime.iOS-14-5 (simulator)
        • macOS (desktop)        • macos                                • darwin-arm64   • macOS 12.6 21G115 darwin-arm
        • Chrome (web)           • chrome                               • web-javascript • Google Chrome 107.0.5304.110
    
    [✓] HTTP Host Availability
        • All required HTTP hosts are available
    
    • No issues found!
    

    cc: @justinmc

  11. guidezpl commented on Mar 14, 2023

    @guidezpl
    Member

    Fixed by #120834

  12. github-actions commented on Mar 28, 2023

    @github-actions

    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.

  13. locked as resolved and limited conversation to collaborators on Mar 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: text inputEntering text in a text field or keyboard related problemsfound in release: 1.21Found to occur in 1.21frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: material_uimaterial_ui package in flutter/packages

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions