我在这一点上遇到错误。结果工作正常,但它显示错误一秒钟。我认为这是因为我在 FutureBuilder 中使用 FutureBuilder。我需要在“未来:”调用两个方法,所以我使用了另一个 FutureBuilder,但它显示错误。
sendOfferButton() {
return FutureBuilder(
initialData: [],
future: getUserProfile(),
builder: (BuildContext context, AsyncSnapshot<dynamic> snapshot) {
cnicCheck = snapshot.data['CNIC'];
return RaisedButton(
padding: EdgeInsets.symmetric(vertical: 10),
child: Text('Send Offer'),
textColor: Colors.white,
color: Colors.green,
onPressed: () {
if (cnicCheck == "verified") {
Navigator.push(
context,
MaterialPageRoute(
builder: (_) => SendOffer(),
),
);
} else {
Navigator.push(
context,
MaterialPageRoute(
builder: (_) => VerifyCNIC(),
),
);
}
},
);
},
);
}
Future getUserProfile() async {
DocumentSnapshot document = await FirebaseFirestore.instance
.collection('Users')
.doc(FirebaseAuth.instance.currentUser.email)
.get();
return document;
}