我有一个 flutter 应用程序,我已成功登录用户并且没有出现任何错误。但是,当我在其中一个按钮中尝试 FirebaseAuth.instance.signOut() 时,它会将用户注销,但会引发此错误。我在下面附加了我的云 Firestore 规则。
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /merchants/{document=**} {
allow read;
}
match /all_merchants/{document=**} {
allow read;
}
match /Types/{document=**} {
allow read;
}
match /Promotions/{document=**} {
allow read;
}
match /search_types/{document=**} {
allow read;
}
match /users/{userId} {
allow read, update, delete: if request.auth.uid == userId;
allow create: if request.auth.uid != null;
match /{document=**}{
allow read, update, create, delete: if request.auth.uid == userId;
}
}
match /users/{email} {
allow read, update, delete: if request.auth.token.email == email;
allow create: if request.auth.token.email != null;
match /{document=**}{
allow read, update, create, delete: if request.auth.token.email == email;
}
}
}
}
(编辑):我的按钮的 Flutter 代码如下:
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
class SignOut extends StatelessWidget {
FirebaseAuth auth = FirebaseAuth.instance;
@override
Widget build(BuildContext context) {
GestureDetector(
onTap: (){
setState(() {
auth.signOut();
});
},
child: ListTile(
dense: true,
leading: Icon(Icons.exit_to_app, color: Colors.red[600], size: 25,),
title: Text('Sign Out',
style: TextStyle(fontFamily: 'Lato', fontSize: 18, fontWeight: FontWeight.w500),),
trailing: Icon(Icons.arrow_forward_ios, color: Colors.black, size: 19,),
),
);
}
}