Home > Mobile >  How to change cursor color in TextField Flutter
How to change cursor color in TextField Flutter

Time:08-16

I'm facing the problem that my cursor color isn't changing when wrapping TextField by Theme widget.

CodePudding user response:

The main problem here is that pointer color isn't changing while wrapping directly it's mentioned in this thread PriceField inactive

active

PriceField active

CodePudding user response:

Solution 1 :-

FYI:- Add "cursorColor" property in theme data

    import 'package:flutter/material.dart';
    
    MaterialApp(
      title: "Solution 1",
      theme: ThemeData(
        cursorColor: Colors.red,
      ),
      home: splashScreen(),
    );

Solution 2 :-

 MaterialApp(
  title: "Solution 2",
  theme: ThemeData(
     textSelectionTheme: TextSelectionThemeData(
        cursorColor: darkPrimarySwatchColor,
        selectionColor: darkPrimarySwatchColor,
        selectionHandleColor: darkPrimarySwatchColor,
     ),
   ),
   home: splashScreen(),
 );
  • Related