Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change cursor color in flutter

Dears, I have 2 qestions in flutter If you don't mind.

1- How to change the color of the cursor as it default blue and I don't like it

2- how can I make the text at the bottom of the screen whatever the screen size. ??

Thank you in advance.

enter image description here

like image 363
Eman Fateen Avatar asked May 05 '19 12:05

Eman Fateen


People also ask

How do you change the cursor pointer color on Flutter?

To change TextField cursor color in Flutter, simply add the cursorColor property and set the color of your choice.

How do you change the cursor color of text field in Flutter?

Example: Change TextField Cursor Color In this Flutter Application, we shall create a TextField and change the cursor color to red. Run the above Flutter Application in an Android smartphone or Android Emulator, and you should see that the cursor color changed to red as shown in the following screenshot.

How do you change cursor size in Flutter?

you can play around with input decoration parameter content-padding to reduce space between The limit area of text field and the TextForm style parameter to make text and cursor height bigger.


2 Answers

put cursorColor: Colors.white, inside the TextFormField

like image 164
Brinda Rathod Avatar answered Oct 04 '22 20:10

Brinda Rathod


This works fine in both iOS and Android:

TextField(cursorColor: Colors.white) 

But, if you like to set it in theme then

SOLUTION 1 - Original answer, recently not tested, also, seems it's deprecated:

I found the solution here:

import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart';  MaterialApp(   title: "Rate your Colleagues",   theme: ThemeData(     // for iOS     cupertinoOverrideTheme: CupertinoThemeData(       primaryColor: Colors.red,     ),     // for others(Android, Fuchsia)     cursorColor: Colors.red,     home: SplashScreen(),   );   ... 

SOLUTION 2 - edited answer - not tested - please give credit to @i4guar

I found the solution here:

MaterialApp(   title: "Rate your Colleagues",   theme: ThemeData(      textSelectionTheme: TextSelectionThemeData(         cursorColor: darkPrimarySwatchColor,         selectionColor: darkPrimarySwatchColor,         selectionHandleColor: darkPrimarySwatchColor,      ),    ),    home: SplashScreen(),  ); 
like image 26
Syed Avatar answered Oct 04 '22 20:10

Syed