【发布时间】:2020-12-23 00:20:33
【问题描述】:
我试图从 firebase 获取数据,并且我想仅在 firebase 集合中有任何可用数据时才显示 Instagram 图标。我使用以下方法从 firebase 获取数据
StreamBuilder(
stream: Firestore.instance.collection("aboutpage").snapshots(),
builder: (context, snapshot) {
if (!snapshot.hasData) {
return Container(
child: Center(
child: SpinKitThreeBounce(
color: Colors.lightBlueAccent,
size: 30.0,
),
),
);
} else {
return Container(
child: ListView.builder(
physics: ClampingScrollPhysics(),
shrinkWrap: true,
itemCount: snapshot.data.documents.length,
itemBuilder: (BuildContext context, int index) {
DocumentSnapshot aboutpage = snapshot.data.documents[index];
return Column(
从 firebase 检索数据时没有问题。问题是当我想显示 Instagram 图标时,如果 firebase 中的数据可用,则使用三元运算符但对我不起作用
"${aboutpage["name"]}" == null
? Container()
: IconButton(Icon: Icons.instagram),
onPressed: (}{}
),
我也尝试过使用"${aboutpage["name"]}".isEmpty,但它对我有用。那么,只有当数据可用且空返回空容器时,我如何才能获取数据?
【问题讨论】:
标签: firebase flutter dart flutter-layout