How to change cursor color in flutter

ぃ、小莉子 提交于 2019-12-20 04:37:16

问题


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.


回答1:


put cursorColor: Colors.white, inside TextFormField




回答2:


For question 1 you can set the cursorColor for theme attribute when calling MaterialApp like the below

new MaterialApp(
title: "Flutter App",
theme: ThemeData(
    cursorColor: Colors.red,
home: HomeScreen(),

)




回答3:


You can use:

TextField( cursorColor: Colors.red),



回答4:


This works fine in both iOS and Android:

TextField(cursorColor: Colors.white)

But, if you like to set it in theme then 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(),
  );
  ...


来源:https://stackoverflow.com/questions/55991901/how-to-change-cursor-color-in-flutter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!