10

How can I change the color of the bubble that appears upon text selection in a Text or TextFormField or .. in Flutter?

Here is the same question but for native code.

HII
  • 3,420
  • 1
  • 14
  • 35

3 Answers3

13

According to this flutter documentation, textSelectionHandleColor is deprecated. You should use selectionHandleColor instead inside TextSelectionThemeData widget like the code below.

  theme: ThemeData(
   
    textSelectionTheme: TextSelectionThemeData(
      cursorColor: Colors.red,
      selectionColor: Colors.green,
      selectionHandleColor: Colors.black,
    ),
  )
KayBee
  • 175
  • 2
  • 8
9

You may use the textSelectionHandleColor property.

Theme(
          data: Theme.of(context).copyWith(
            textSelectionHandleColor: Colors.green, 
          ),
          child: TextField(),
        );
Darish
  • 11,032
  • 5
  • 50
  • 70
0

In case of iOS TextField, i've found no other solution than adding the snippet below to the top level MaterialApp like this:

MaterialApp => theme: ThemeData( snippet )

snippet: cupertinoOverrideTheme: CupertinoThemeData( primaryColor: Color(0xff554270), ),

i couldn't apply this snippet by wrapping the TextField with Theme(data: Theme.of(context).copyWith( ... did not work.. dunno why ]: (maybe this one would be my fault in somewhere but adding it to the app lv definitely worked tho)

Hope this answer help future iOS wanderers [:

tsitixe
  • 1,851
  • 3
  • 14
  • 24