flutter 错误:未为类“ThemeData”定义getter“cursorColor”

ttcibm8c  于 2023-05-19  发布在  Flutter
关注(0)|答案(2)|浏览(583)

每次我尝试运行flutter应用程序时都会出现此错误。它只是抛出下面的错误,然后编译器退出。

../../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,
                                                           ^^^^^^^^^^^

我看不到任何错误。我已经尝试运行扑动医生,没有显示任何问题。我使用Flutter 3.1.0。我也已经运行了‘flutter pub升级‘和‘flutter pub升级--主要版本‘,但没有运气。

ugmeyewa

ugmeyewa1#

我想你用的是旧版本的flutter。
您可以执行flutter upgradeflutter upgrade --force
当前版本的flutter是3.3.1Theme.of(context).cursorColor,已替换为

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

wa7juj8i2#

删除你的package.lock文件,看起来它已经缓存了旧版本。然后再运行flutter pub get,升级你的flutter。

相关问题