错误:在升级到Flutter 3.10后,类’ThemeData’没有定义’accentColor’的获取器。

huangapple go评论78阅读模式
英文:

Error: The getter 'accentColor' isn't defined for the class 'ThemeData' after updating to Flutter 3.10

问题

I'm getting this error after updating to 3.10, and I don't reference accentColor in code. I assume it's one of the libraries that use this line. How do I check which one it is?

Error:

: Error: The getter 'accentColor' isn't defined for the class 'ThemeData'.
rectangle_indicator.dart:17

  • 'ThemeData' is from 'package:flutter/src/material/theme_data.dart' ('../../flutter/packages/flutter/lib/src/material/theme_data.dart').
    theme_data.dart:1
    Try correcting the name to the name of an existing getter, or defining a getter or field named 'accentColor'.
    final borderColor = this.borderColor ?? Theme.of(context).accentColor;
    ^^^^^^^^^^^
    : Error: The getter 'accentColor' isn't defined for the class 'ThemeData'.
    triangle_indicator.dart:20
  • 'ThemeData' is from 'package:flutter/src/material/theme_data.dart' ('../../flutter/packages/flutter/lib/src/material/theme_data.dart').
    theme_data.dart:1
    Try correcting the name to the name of an existing getter, or defining a getter or field named 'accentColor'.
    color: color ?? theme.accentColor,
    ^^^^^^^^^^^

Dependencies:

dependencies:
  flutter:
    sdk: flutter

  firebase_core: ^2.8.0
  firebase_analytics: ^10.1.6
  firebase_performance: ^0.9.0+16
  firebase_crashlytics: ^3.0.17

  shared_preferences: ^2.0.15
  provider: ^6.0.4
  url_launcher: ^6.1.6
  flutter_boxicons: ^3.0.0
  material_design_icons_flutter: ^6.0.7096

  flutter_localizations:
    sdk: flutter
  flutter_fortune_wheel: ^1.2.0
  dynamic_color: ^1.6.3
  flutter_hooks: ^0.18.6

  google_mobile_ads: ^3.0.0
  purchases_flutter: ^4.11.1
  font_awesome_flutter: ^10.4.0

dev_dependencies:
  flutter_test:
    sdk: flutter

  flutter_lints: ^2.0.1
  flutter_native_splash: ^2.2.19
  dependency_validator: ^3.0.0
英文:

I'm getting this error after updating to 3.10, and I don't reference accentColor in code. I assume it's one of the libraries that use this line. How do I check which one it is?

Error:

: Error: The getter 'accentColor' isn't defined for the class 'ThemeData'.
rectangle_indicator.dart:17
- 'ThemeData' is from 'package:flutter/src/material/theme_data.dart' ('../../flutter/packages/flutter/lib/src/material/theme_data.dart').
theme_data.dart:1
Try correcting the name to the name of an existing getter, or defining a getter or field named 'accentColor'.
    final borderColor = this.borderColor ?? Theme.of(context).accentColor;
                                                              ^^^^^^^^^^^
: Error: The getter 'accentColor' isn't defined for the class 'ThemeData'.
triangle_indicator.dart:20
- 'ThemeData' is from 'package:flutter/src/material/theme_data.dart' ('../../flutter/packages/flutter/lib/src/material/theme_data.dart').
theme_data.dart:1
Try correcting the name to the name of an existing getter, or defining a getter or field named 'accentColor'.
          color: color ?? theme.accentColor,
                                ^^^^^^^^^^^

Dependencies:

dependencies:
  flutter:
    sdk: flutter

  firebase_core: ^2.8.0
  firebase_analytics: ^10.1.6
  firebase_performance: ^0.9.0+16
  firebase_crashlytics: ^3.0.17

  shared_preferences: ^2.0.15
  provider: ^6.0.4
  url_launcher: ^6.1.6
  flutter_boxicons: ^3.0.0
  material_design_icons_flutter: ^6.0.7096

  flutter_localizations:
    sdk: flutter
  flutter_fortune_wheel: ^1.2.0
  dynamic_color: ^1.6.3
  flutter_hooks: ^0.18.6

  google_mobile_ads: ^3.0.0
  purchases_flutter: ^4.11.1
  font_awesome_flutter: ^10.4.0

dev_dependencies:
  flutter_test:
    sdk: flutter

  flutter_lints: ^2.0.1
  flutter_native_splash: ^2.2.19
  dependency_validator: ^3.0.0

答案1

得分: 1

It says rectangle_indicator.dart:17 and triangle_indicator.dart:20 which you can see comes from the flutter_fortune_wheel library.

英文:

It says rectangle_indicator.dart:17 and triangle_indicator.dart:20 which you can see comes from the flutter_fortune_wheel library.

答案2

得分: 0

The accentColor is removed in the new version of flutter.
You can use colorScheme.secondaryColor instead of accent color.

英文:

The accentColor is removed in the new version of flutter.
You can use colorScheme.secondayColor instead of accentcolor.

答案3

得分: 0

尝试在Android Studio终端中运行flutter clean,然后执行"使缓存无效并重启IDE"。

英文:

Try running flutter clean in the Android Studio terminal, and Do Invalidate caches and restart the IDE.

huangapple
  • 本文由 发表于 2023年5月11日 18:29:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/76226640.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定