我对Firebase规则有麻烦。当我将以下读取和写入规则设置为true时,运行以下代码时,它们都可以正常运行。
但是,当我将两个规则都编辑为“ auth!= null”时,出现红色的死亡屏幕! 用户已通过身份验证,我可以打印出快照数据。 我尝试在Provider.of中打印提取的解码json数据,它显示为“ {错误:权限被拒绝}”
我收到以下错误:
The following NoSuchMethodError was thrown building FutureBuilder<List<void>>(dirty, state: _FutureBuilderState<List<void>>#16171):
'[]'
Dynamic call of null.
Receiver: null
Arguments: [0]
The relevant error-causing widget was
FutureBuilder<List<void>>
When the exception was thrown, this was the stack
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 216:49 throw_
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 721:3 defaultNoSuchMethod
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 715:56 noSuchMethod
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 270:9 _checkAndCall
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 388:10 callMethod
════════════════════════════════════════════════════════════════════════════════
这是代码:
home: StreamBuilder<User>(
stream: FirebaseAuth.instance.authStateChanges(),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return Scaffold(
body: Center(
child: CircularProgressIndicator(
valueColor: AlwaysStoppedAnimation<Color>(Colors.orange),
)));
} else if (snapshot.data == null) {
return AuthScreen();
} else {
return FutureBuilder(
future: Future.wait([
Provider.of<Products>(context, listen: false)
.fetchAndSetProducts(),
Provider.of<Orders>(context, listen: false)
.setAndFetchOrders(FirebaseAuth.instance.currentUser.uid),
Provider.of<Products>(context, listen: false)
.fetchAndSetBannerMessage(),
Provider.of<ProfileProvider>(context, listen: false)
.downloadContactAndAddressInfo(
FirebaseAuth.instance.currentUser),
Provider.of<AdminOrders>(context, listen: false)
.setAndFetchExpenses()
]),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return Scaffold(
body: Center(
child: CircularProgressIndicator(
valueColor: AlwaysStoppedAnimation<Color>(Colors.orange),
)));
} else if (snapshot.connectionState == ConnectionState.done &&
snapshot.data[0] == true) {
return LandingPage();
} else {
return NoInternetErrorDialog(h1: _h1);
}
},
);
}
},
),