没有构造函数“文本”。与“Text”类中声明的匹配参数

iAk*_*kki 5 nosuchmethoderror flutter hot-reload

我在现有的 iOS 应用程序中使用 flutter 模块。在进行更改时,我经常使用热重载来查看输出。直到昨天它都工作正常,但是当我现在使用热重载时,它给了我一个例外:

The following NoSuchMethodError was thrown building PurchaseOrders(dirty, dependencies: [_InheritedTheme, _LocalizationsScope-[GlobalKey#4a83e]], state: _PurchaseOrdersState#a115b):
No constructor 'Text.' with matching arguments declared in class 'Text'.
Receiver: Text
Tried calling: new Text.()
Found: new Text.(String, {Key key, TextStyle style, StrutStyle strutStyle, TextAlign textAlign, TextDirection textDirection, Locale locale, bool softWrap, TextOverflow overflow, double textScaleFactor, int maxLines, String semanticsLabel, TextWidthBasis textWidthBasis, TextHeightBehavior textHeightBehavior}) => Text

Widget creation tracking is currently disabled. Enabling it enables improved error messages. It can be enabled by passing `--track-widget-creation` to `flutter run` or `flutter test`.
Run Code Online (Sandbox Code Playgroud)

我尝试过:文件->使缓存无效/重新启动。但并没有帮助我。每次我做出任何微小的改变时,我都必须停下来跑步。可能是什么问题 ?

Mad*_*mar 28

我也遇到了类似的错误,但当我使用hot restart应用程序而不是 hot reload.


Oma*_*att 0

您想在 Text() 上使用什么对象?Text.()正在尝试使用错误状态Text“没有构造函数‘文本’。” 与类“Text”中声明的匹配参数。” 。Text 期望至少有一个 String,并且由于没有构造函数匹配Text.(),因此引发了错误。

您是否使用某种文本本地化?根据我的经验,如果您使用flutter_localizations,则需要至少构建一次应用程序才能生成本地化字符串。否则,您需要提供更多详细信息,以便我们更好地了解该问题。