Error: The getter 'cursorColor' isn't defined for the class 'ThemeData'

Viewed 44

I'm getting this error each time I try to run my flutter application. it just throw the error below and the compiler exits.

../../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/nb_utils-3.3.0+13/lib/src/AppTextField.dart:181:60: Error: The getter 'cursorColor'     
isn't defined for the class 'ThemeData'.
 - 'ThemeData' is from 'package:flutter/src/material/theme_data.dart'
 ('/C:/flutter%20sdk/flutter/packages/flutter/lib/src/material/theme_data.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'cursorColor'.
      cursorColor: widget.cursorColor ?? Theme.of(context).cursorColor,
                                                           ^^^^^^^^^^^

I cannot see any errors. I have already tried running flutter doctor no issues displayed. I am using flutter 3.1.0. I have also already run 'flutter pub upgrade' and 'flutter pub upgrade --major versions' but no luck.

1 Answers

I think you are using old version of flutter.

You can do flutter upgrade or flutter upgrade --force

The current version of flutter is 3.3.1 Theme.of(context).cursorColor has been replaced with

Theme.of(context).textSelectionTheme.cursorColor,
Related