1

I am creating this application in flutter where I have this text field. I want to change the color of this cursor balloon but I'm not sure how can I. Any help will be appreciated. enter image description here

dipansh
  • 331
  • 3
  • 15

1 Answers1

0

Wrap your textfield widget with a Theme widget and set the textSelectionHandleColor parameter to your desired color.

Theme(
   data: Theme.of(context).copyWith(
     textSelectionTheme: TextSelectionThemeData(
      cursorColor: Colors.red,
      selectionColor: Colors.green,
      selectionHandleColor: Colors.black,
    ), 
   ),
   child: TextFormField(),
);

Or you can make it uniform across you app by setting the theme parameter of the MaterialApp widget like so:

return MaterialApp(
        title: 'App Name',
        debugShowCheckedModeBanner: false,
        theme: ThemeData(
          textSelectionTheme: const TextSelectionThemeData(
            cursorColor: Colors.red,
                  selectionColor: Colors.blue,
                  selectionHandleColor: Colors.purple,
          ),
          
          //...Other theme color configurations here
        ),
         home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
Benedict
  • 441
  • 4
  • 14