HII
HII

Reputation: 4149

How to change color of the bubble (under cursor) on EditText in Flutter

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.

Upvotes: 12

Views: 7664

Answers (3)

tsitixe
tsitixe

Reputation: 2361

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 [:

Upvotes: 1

KayBee
KayBee

Reputation: 305

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,
    ),
  )

Upvotes: 16

Darish
Darish

Reputation: 11501

You may use the textSelectionHandleColor property.

Theme(
          data: Theme.of(context).copyWith(
            textSelectionHandleColor: Colors.green, 
          ),
          child: TextField(),
        );

Upvotes: 10

Related Questions