How to change icon cursor of Textfield in Flutter?

Viewed 1679

How to change the icon cursor of Textfield in Flutter?

change_icon_cursor

(This image is screen shoot on Android)

I want to change the icon or change colour of the cursor.

4 Answers

textSelectionHandleColor is deprecated and shouldn't be used. Use TextSelectionThemeData.selectionHandleColor instead.

Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(
          ...
          textSelectionTheme: TextSelectionThemeData(selectionHandleColor: Colors.black),
          ...
    );
}

You mean the handler selector, not the cursor, right?

Yo can apply that change using textSelectionHandleColor in the root of your app using ThemeData.

I don't think it is possible for individual TextField

Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(
          textSelectionColor: Colors.yellow,
          textSelectionHandleColor: Colors.red)
    );
}
ThemeData(
  textSelectionTheme: TextSelectionThemeData(
    cursorColor: pink,
    selectionHandleColor: pink,
    selectionColor: pink
  )
);
TextField(
  cursorColor: Colors.pink,
)
Related