Skip to content

TextFormField - when validation fails, cursor color is assigned to be the same as the error text color #135580

@liranzairi

Description

@liranzairi

Is there an existing issue for this?

Steps to reproduce

Hi, I'm reopening this issue: #134451 because it was locked without solving

  1. Run the code sample
  2. Tap on the text field to set the focus to it
  3. The cursor color is green as expected
  4. Write something, no matter what, so the "Invalid" error text will appear in red under the text field

Expected results

The cursor color should stay green.

Actual results

The cursor color turns red like the error text color.
If this is intended, then the documentation of TextFormField should be updated, although I don't see the point in keeping this behavior.

Code sample

Code sample
import 'package:flutter/material.dart';

void main() {
  runApp(const MainApp());
}

class MainApp extends StatelessWidget {
  const MainApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Form(
          autovalidateMode: AutovalidateMode.always,
          child: Center(
            child: Padding(
              padding: const EdgeInsets.all(20),
              child: TextFormField(
                cursorColor: Colors.green,
                validator: (value) {
                  if (value?.isNotEmpty == true) return 'Invalid';
                  return null;
                },
              ),
            ),
          ),
        ),
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration

Logs

Logs

Flutter Doctor output

Doctor output
[!] Flutter (Channel unknown, 3.10.5, on macOS 13.3 22E252 darwin-arm64, locale en-IL)
    ! Flutter version 3.10.5 on channel unknown at /Users/liran/code/flutter
      Currently on an unknown channel. Run `flutter channel` to switch to an official channel.
      If that doesn't fix the issue, reinstall Flutter by following instructions at https://flutter.dev/docs/get-started/install.
    ! Unknown upstream repository.
      Reinstall Flutter by following instructions at https://flutter.dev/docs/get-started/install.
    • Framework revision 796c8ef792 (3 months ago), 2023-06-13 15:51:02 -0700
    • Engine revision 45f6e00911
    • Dart version 3.0.5
    • 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 /Users/liran/Library/Android/sdk
    • Platform android-34, build-tools 32.1.0-rc1
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.3.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14E300c
    • CocoaPods version 1.12.1

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

[✓] Android Studio (version 2021.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 11.0.11+0-b60-7772763)

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

[✓] Connected device (4 available)
    • sdk gphone64 arm64 (mobile) • emulator-5554             • android-arm64  • Android 14 (API 34) (emulator)
    • Liran's iPhone (mobile)     • 00008101-000265A20C84001E • ios            • iOS 16.6 20G75
    • macOS (desktop)             • macos                     • darwin-arm64   • macOS 13.3 22E252 darwin-arm64
    • Chrome (web)                • chrome                    • web-javascript • Google Chrome 116.0.5845.179

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: text inputEntering text in a text field or keyboard related problemsf: material designflutter/packages/flutter/material repository.found in release: 3.13Found to occur in 3.13found in release: 3.15Found to occur in 3.15has reproducible stepsThe issue has been confirmed reproducible and is ready to work onteam-designOwned by Design Languages teamtriaged-designTriaged by Design Languages team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions