Home > Software design >  how to fix string must be provide to a text widget?
how to fix string must be provide to a text widget?

Time:11-16

How to fix this problem this string cannot be provided in the text widget. How can I solve this? My code: code

CodePudding user response:

I think the problem is that fullName is of type String? instead of String. That means you need to ensure it is not null.

Either by enforcing a null check

Text(fullName!)

or by providing a fallback value

Text(fullName ?? 'fallback')

or by only showing the text if fullName is not null like

if (fullName != null)
  Text(fullName)

CodePudding user response:

Because your fullName text canbe null, try handle fullName null case:

Text(
      fullName ?? '',
      style: boldTextStyle.copyWith(fontSize: 18),
    )
  • Related