body: StreamBuilder(
stream: Firestore.instance.collection('students').document(_userId).snapshots(),
builder: (context,snapshot) {
return Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
SizedBox(
height: 20.0,
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(left:20.0),
child: Align(
alignment: Alignment.centerRight,
child: CircleAvatar(
radius: 100,
backgroundColor: Colors.white,
child: ClipOval(
child: new SizedBox(
width: 180.0,
height: 180.0,
child: (_image!=null)?Image.file(
_image,
fit: BoxFit.fill,
):
Image.network(""),
),
),
),
),
),
Padding(
padding: EdgeInsets.only(top: 60.0),
child: IconButton(
icon: Icon(
Icons.camera,
size: 30.0,
),
onPressed: () {
getImage();
},
),
),
],
),
SizedBox(
height: 20.0,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(left:40.0),
child: Align(
alignment: Alignment.center,
child: Container(
child: Column(
children: <Widget>[
Align(
alignment: Alignment.center,
child: Text('Student Name',
style: TextStyle(
color: Colors.white, fontSize: 20.0)),
),
Align(
alignment: Alignment.center,
child: Text(snapshot.data['first_name'],
style: TextStyle(
color: Colors.black,
fontSize: 18.0,
)),
),
],
),
),
),
),
我想显示来自Cloud Firestore的学生姓名,但在首次加载时出现错误,但是hotreload之后该应用程序可以正常运行。 这是我的学生证检索功能
FirebaseAuth.instance.currentUser().then((user) {
_userId = user.uid;
});
我正在使用此ID来检索特定的学生详细信息,但是在第一次加载时给出错误,错误是enter image description here 数据库快照为enter image description here