【发布时间】:2020-03-31 03:32:24
【问题描述】:
我正在为我的应用程序创建一个通知中心,它包含一些用于标题和正文的长字符串,它总是会导致溢出,我尝试使用扩展小部件,以及以下这些堆栈溢出问题:Question 1,Question 2 但我无法将它应用到我的代码中,这就是它现在的样子:
我从我的 firebase cloud firestore 获取文本,并使用列表视图输出文本。
标题文本是这样的:“Allen Indefenzo 已撤销同意您访问他/她的数据”
正文是这样的:“他/她已删除您的所有访问权限,您将无法再查看/更改他的数据,再次访问要求用户给您他/她再次特殊代码。”
这是我的代码:
Container(
color: Colors.white,
child: StreamBuilder(
stream: db
.collection('users')
.document(userData.userID)
.collection('notifications')
.snapshots(),
builder: (BuildContext context, AsyncSnapshot snapshot) {
if (!snapshot.hasData) {
return Center(
child: CircularProgressIndicator(),
);
}
if (snapshot.data.documents.length != 0) {
return ListView.builder(
itemCount: snapshot.data.documents.length,
itemBuilder: (BuildContext context, int index) {
return Container(
child: Row(
children: <Widget>[
Container(
height: 150,
width: 100,
child: Image(
image: NetworkImage(
snapshot.data.documents[index]['dpURL']), fit: BoxFit.contain,
),
),
Column(
children: <Widget>[
Container(
height: 50,
width: MediaQuery.of(context).size.width * 0.8,
child:
Text(snapshot.data.documents[index]['title']),
),
Container(
height: 50,
width: MediaQuery.of(context).size.width * 0.8,
child:
Text(snapshot.data.documents[index]['body']),
),
],
),
],
),
);
},
);
}
},
),
),
感谢您提供任何帮助,如果您能解释一下,那就太棒了!非常感谢!
【问题讨论】: