flutter - 流式传输数据时如何通过小部件构建条件?
问题描述
我正在将集合作为快照从 Firestore 流式传输到我的颤振项目。当集合中不存在变量 im 循环时,我如何在文本小部件中写入,例如“空”?
child: Column(
children: <Widget>[
if (title != null)
{
Text(
title,
),
),
}
else {
Text('empty'),
解决方案
您可以使用如下代码:-
String title = '';
return Container(
child: Column(
children: <Widget>[
Text(title.isNotEmpty ? title : 'empty')
],
),
);
推荐阅读
- c - 在 Windows MSVC 上,是否可以将一些 .obj 合并为一个 .obj?如果是,我该怎么做?
- spring-boot - 如何通过 HTTPS 使用 springdoc-openapi-maven-plugin
- swift - 链接 swift combine 发布者并接收每个结果
- angular - 无法创建新的角度项目
- c# - 如何从列表中删除对象的实例?
- twig - 如何使用 Ocmod 在 Opencart 3.0.2.0 中的 product.twig(catalog/view/theme/default/template/product/) 中添加自定义表单组
- php - 如何增量添加到 multidim 数组 PHP?
- react-native - 点击图标组件时,在 iOS 和 Android 中以原生组件样式显示选择器
- javascript - 过渡和鼠标悬停
- google-sheets - 谷歌表格:在另一个单元格中打印输出