简体   繁体   English

升级到最新版本后出现颤振错误

[英]Flutter Error after upgrade to latest version

recently updated my flutter to v2.5.3 and I'm getting the following error :最近将我的颤振更新到 v2.5.3,我收到以下错误:

371:41: Error: The getter 'subhead' isn't defined for the class 'TextTheme'. 371:41:错误:没有为类“TextTheme”定义吸气剂“副标题”。

  • 'TextTheme' is from 'package:flutter/src/material/text_theme.dart' ('/C:/src/flutter/packages/flutter/lib/src/material/text_theme.dart'). “TextTheme”来自“package:flutter/src/material/text_theme.dart”(“/C:/src/flutter/packages/flutter/lib/src/material/text_theme.dart”)。 Try correcting the name to the name of an existing getter, or defining a getter or field named 'subhead'.尝试将名称更正为现有 getter 的名称,或定义一个名为“subhead”的 getter 或字段。 ? ? Theme.of(context).textTheme.subhead ^^^^^^^ ../../../../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/searchable_dropdown-1.1.3/lib/searchable_dropdown.dart:374:16: Error: The getter 'subhead' isn't defined for the class 'TextTheme'. Theme.of(context).textTheme.subhead ^^^^^^^ ../../../../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/searchable_dropdown-1.1.3 /lib/searchable_dropdown.dart:374:16:错误:没有为类“TextTheme”定义吸气剂“副标题”。
  • 'TextTheme' is from 'package:flutter/src/material/text_theme.dart' ('/C:/src/flutter/packages/flutter/lib/src/material/text_theme.dart'). “TextTheme”来自“package:flutter/src/material/text_theme.dart”(“/C:/src/flutter/packages/flutter/lib/src/material/text_theme.dart”)。 Try correcting the name to the name of an existing getter, or defining a getter or field named 'subhead'.尝试将名称更正为现有 getter 的名称,或定义一个名为“subhead”的 getter 或字段。 .subhead ^^^^^^^ .副标题^^^^^^^

The error is somewhat self explanatory: The subhead property no longer exists in newer versions of the TextTheme , as per the 2018 Material Design guidelines.该错误有点不言自明:根据 2018 Material Design 指南,新版本的TextTheme中不再存在subhead属性。

If I'm not mistaken you should instead use subtitle1 as a closest replacement, but feel free to take a look at the Flutter documentation to find out which property to use instead.如果我没记错的话,您应该改用subtitle1作为最接近的替代品,但请随时查看Flutter 文档以找出要使用的属性。

See also this other SO question that also uses subhead :另请参阅也使用subhead的其他 SO 问题:

How to use Flutter AppTheme TextTheme without overriding automatic text color如何在不覆盖自动文本颜色的情况下使用 Flutter AppTheme TextTheme

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM