Home > Back-end >  Flutter - Change color of selected text in a Textfield
Flutter - Change color of selected text in a Textfield

Time:02-18

I have a Searchbar and due to my app theming, the text inside becomes hard to read when its selected. I would like to know if there is a way to set a different text color when it's selected.

Searchbar

Thanks in advance!

CodePudding user response:

Wrap with Theme and use copyWith to preserve other theme data.

Theme(
  data: Theme.of(context).copyWith(
    textSelectionTheme: TextSelectionThemeData(
      selectionColor: Color.fromARGB(255, 0, 20, 255),
    ),
  ),
  child: TextField(),
),

CodePudding user response:

You can inspect this Change the Highlight Color of selected text

text selection color deprecated flutter after that using Theme best way as I research.

  • Related