【发布时间】:2022-01-23 18:57:33
【问题描述】:
您好,每次我在 Flutter 应用程序上单击通知详细信息时,都会出现此错误消息并变红,您可以帮我解决此错误。
请有人帮我在这里找不到解决方案
更新:我不确定这是否是解决问题的正确代码
Align(
alignment: Alignment.centerRight,
child: IconButton(
icon: Icon(Icons.close),
onPressed: () => Navigator.of(context).pop(),
),
),
Container(
height: 150, width: MediaQuery.of(context).size.width,
margin: EdgeInsets.symmetric(horizontal: Dimensions.PADDING_SIZE_LARGE),
decoration: BoxDecoration(borderRadius: BorderRadius.circular(Dimensions.RADIUS_SMALL), color: Theme.of(context).primaryColor.withOpacity(0.20)),
child: ClipRRect(
borderRadius: BorderRadius.circular(Dimensions.RADIUS_SMALL),
child: FadeInImage.assetNetwork(
placeholder: Images.placeholder,
image: '${Get.find<SplashController>().configModel.baseUrls.notificationImageUrl}/${notificationModel.image}',
height: 150, width: MediaQuery.of(context).size.width, fit: BoxFit.cover,
imageErrorBuilder: (c, o, s) => Image.asset(
Images.placeholder, height: 150,
width: MediaQuery.of(context).size.width, fit: BoxFit.cover,
),
),
),
),
SizedBox(height: Dimensions.PADDING_SIZE_LARGE),
Padding(
padding: EdgeInsets.symmetric(horizontal: Dimensions.PADDING_SIZE_LARGE),
child: Text(
notificationModel.title,
textAlign: TextAlign.center,
style: robotoMedium.copyWith(color: Theme.of(context).primaryColor, fontSize: Dimensions.FONT_SIZE_LARGE),
),
),
Padding(
padding: EdgeInsets.fromLTRB(20, 10, 20, 20),
child: Text(
notificationModel.description,
textAlign: TextAlign.center,
style: robotoRegular.copyWith(color: Theme.of(context).disabledColor),
),
),
],
),
),
);
} }
当我将代码更新为 Text(someVariable ?? 'Default text if varible is null') mobile screenshot
我的 text.dart 错误位置
assert(
data != null,
'A non-null String must be provided to a Text widget.',
),
textSpan = null,
super(key: key);
【问题讨论】:
-
您正在某处使用
Text小部件,该小部件接受一些值为null的变量。 -
添加一些代码,以便我们可以看到您在做什么以及可能出现的问题。
-
您好,感谢您的回复,我在哪里可以获得与此问题相关的代码,是否在 main.dart 文件中?
标签: flutter