No constructor 'Text.' with matching arguments declared in class 'Text'

Viewed 4635

I'm using flutter module in my existing iOS app. While making changes I often use hot reload to see the output. It was working fine until yesterday, but when I use hot reload now, its giving me the exception:

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`.

I've tried: File -> Invalidate Caches/Restart. But didn't help me out. I have to stop and run every time I make any small change. What could be the issue ?

2 Answers

I also faced a similar error, but it resolved when I hot restart the app instead of hot reload.

What Object are you trying to use on Text()? The error states Text.() is being tried to be used on Text: "No constructor 'Text.' with matching arguments declared in class 'Text'.". Text expects to have at least a String, and since no constructor matches Text.(), an error was thrown.

Are you using some kind of Localization for Text? In my experience, if you're using flutter_localizations, the app needs to be built at least once to generate the localized Strings. Otherwise, you'll need to provide more details for us to better understand the issue.

Related