Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change icon cursor of Textfield in Flutter?

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.

like image 840
Huu Bao Nguyen Avatar asked Oct 27 '25 09:10

Huu Bao Nguyen


2 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),
          ...
    );
}
like image 145
Momo Avatar answered Oct 30 '25 00:10

Momo


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)
    );
}
like image 45
encubos Avatar answered Oct 29 '25 22:10

encubos



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!