我試圖在他是 auth == true 時再次給用戶打電話。當用戶按下他需要被稱為同一個用戶。任何解決方案?
class upload extends StatefulWidget {
String? userId;
upload({Key? key, this.userId}) : super(key: key);
@override
State<upload> createState() => _uploadState();
}
class _uploadState extends State<upload> {
File? file;
String? downloadUrl;
//.......
//.......
//.......
@override
void initState() {
super.initState();
FirebaseFirestore.instance
.collection("users")
.doc(user!.uid)
.get()
.then((value) {
this.loggedInUser = usermodel.fromMap(value.data());
setState(() {});
});
}
//...........
//...........
onPressed: () => selectImage(context, userId: loggedInUser.uid),
~~~!
uj5u.com熱心網友回復:
在你的selectImage
函式中,如果你這樣定義它:
selectImage(BuildContext context, String userId) {
//....etc
那么當您呼叫該方法時,它應該如下所示:
onPressed: () => selectImage(context, loggedInUser.uid),
因為您使用的是位置引數,而不是命名引數。
如果要使用命名,請將其更改為:
selectImage({required BuildContext context, required String userId}) {
//....etc
onPressed: () => selectImage(context: context, userId: loggedInUser.uid),
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/470235.html