No constructor 'Text.' with matching arguments declared in class 'Text'
Asked Answered
W

2

7

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 ?

Woodcock answered 17/7, 2020 at 15:20 Comment(3)
The error says you are calling Text() constructor without parameter but you should be calling Text("text"). Are you sure you did not remove the parameter by mistake?Retraction
No. Its working fine with normal run, but the issue is with hot reload.Woodcock
Are you running your app in flutter beta? Can you please provide your flutter doctor -v with latest stable, your flutter attach --verbose and a complete reproducible minimal code sample? It seems that this GitHub post is related to your issue.Tefillin
C
33

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

Channel answered 4/11, 2021 at 7:14 Comment(1)
flutter tip: always make hot-restart before after pass hours searching about solution ahahJuvenilia
F
0

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.

Footpace answered 13/9, 2021 at 10:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.