fluttercursortextfield

Change TextField cursor bottom indicator in Flutter


I want to change cursor color, completely. I have added following code:

TextField(
  ...
  cursorColor: myBlueColor,
)

However, this does not change bottom indicator (when you select part of the text/text position) - it is still purple:

enter image description here

Can somebody help how to achieve this? I am using Flutter 3.16.0.


Solution

  • In your MaterialApp, you can change the selectionHandleColor for the TextSelectionThemeData:

    theme: ThemeData(
      textSelectionTheme: TextSelectionThemeData(
        cursorColor: Colors.red,
        selectionColor: Colors.green,
        selectionHandleColor: Colors.black,
      ),
    )