Reputation: 93
I'm getting this error "NoSuchMethodError: The method '+' was called on null. Receiver: null Tried calling: +()"
But on the simulator and my phone, I can see the page perfectly and no error is shown. When other people installed the app on their devices, they get this error. I'm not sure why I can't reproduce it on debugging, but leaves me unsure on what to fix.
This is the only code snippets where I use +
Text(AppLocalizations.of(context).translate("Member since_") + "${timeago.format(user.timestamp.toDate())}",
style: TextStyle(color: Colors.black45))
is it wrong to use + like this to combine strings? It has worked before, and still works on the simulator like I said.
Upvotes: 1
Views: 52
Reputation: 524
I think the problem is on ${timeago.format(user.timestamp.toDate())} because this the only varialbe here(Please make sure your JSON translate "Member since_"), Maybe there is null on user.timestamp.toDate() So you should use safe null variable like this:
final String timeRegist = user?.timestamp?.toDate() ?? '';
Text(AppLocalizations.of(context).translate("Member since_") + "$timeRegist )}",
style: TextStyle(color: Colors.black45))
Upvotes: 1