E/StorageUtil(6584):获取令牌java.util.concurrent.ExecutionExcept



我收到以下与我的Firebase代码有关的错误,该代码用于保存图像、日期和废弃项目的数量。或者这可能是一个与我的Firebase配置有关的错误?

import 'dart:io';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_storage/firebase_storage.dart';
import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';
import 'dart:async';
import 'package:wasteagram/model/waste.dart';
import 'package:path/path.dart' as path;
import 'package:uuid/uuid.dart';
class CameraScreen extends StatefulWidget {
final bool isUpdating;  

CameraScreen({this.isUpdating = true}); 
@override
_CameraScreenState createState() => _CameraScreenState();
}
class _CameraScreenState extends State<CameraScreen> {
final GlobalKey<FormState> _formKey = GlobalKey<FormState>(); 
Waste _currentWaste = Waste(); 
Widget _buildDateField() {
return Form(
key: _formKey, 
child: TextFormField(
decoration: InputDecoration(labelText: 'Date'),
keyboardType: TextInputType.text,
style: TextStyle(fontSize: 20), 
validator: (String value) {
if(value.isEmpty){
return 'Date required'; 
}
if(value.length < 3 || value.length > 20) {
return 'Name must be more than 3 or less than 20'; 
}
return null;
},
onSaved: (String value) {
_currentWaste.wastedate = value; 
},
),
);
}
Widget _buildWasteNumber() {
return Form(
child: TextFormField(
decoration: InputDecoration(labelText: 'Number'),
keyboardType: TextInputType.number,
style: TextStyle(fontSize: 20), 
validator: (value) {
if(value.isEmpty){
return 'Number required'; 
}
return null;
},
onSaved: (String value) {
String wasteNum = _currentWaste.wastenumber.toString();
wasteNum = value; 
},
),
);
}
_saveWaste(context) {
print("saveWaste Called"); 
if(!_formKey.currentState.validate()) {
return "FALSE"; 
}
_formKey.currentState.save(); 
print("form saved");
uploadItems(_currentWaste, widget.isUpdating, image);  

print("date ${_currentWaste.wastedate}"); 
print("number ${_currentWaste.wastenumber.toString()}");
print("_imageFile ${image.toString()}");
}
File image; 
void getImage() async {
image = await ImagePicker.pickImage(source: ImageSource.gallery); 
setState( () {}); 
}
@override 
Widget build(BuildContext context) {
if (image == null) {
return Scaffold(
appBar: AppBar(
title: Text('Wasteagram')
), 
body: Center(
child: RaisedButton(
child: Text('Select Photo'),
onPressed: () {
getImage(); 
},
),
),
); 
} else {
return Scaffold(
appBar: AppBar(
title: Text('Wasteagram')
), 
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.file(image),
SizedBox(height: 40), 
RaisedButton(
child: Text('Select Photo'),
onPressed: () {
getImage(); 
}
), 
_buildDateField(),
_buildWasteNumber(),
],
),
floatingActionButton: FloatingActionButton(
onPressed: () => _saveWaste(context),
child: Icon(Icons.save),
foregroundColor: Colors.white,
),
); 
}
}
}
uploadItems(Waste waste, bool isUpdating, File localFile) async {
if (localFile != null) {
print("uploading image"); 
var fileExtension = path.extension(localFile.path); 
print(fileExtension); 
var uuid = Uuid().v4(); 
final StorageReference firebaseStorageRef = 
FirebaseStorage.instance.ref().child('/$uuid$fileExtension'); 
await firebaseStorageRef.putFile(localFile).onComplete.catchError(
(onError){
print(onError); 
return false; 
}
); 
String url = await firebaseStorageRef.getDownloadURL(); 
print("download url: $url"); 
_uploadWaste(waste, isUpdating, imageUrl: url); 
} else {
print("skipping image upload"); 
_uploadWaste(waste, isUpdating); 
}
}
_uploadWaste(Waste waste, bool isUpdating, {String imageUrl}) async {
CollectionReference wasteRef = Firestore.instance.collection('todolist'); 
if(imageUrl != null) {
waste.image = imageUrl; 
}
if(isUpdating) {
waste.updatedAt = Timestamp.now(); 
await wasteRef.document(waste.id).updateData(waste.toMap()); 
print("updated waste with id: ${waste.id}"); 
} else {
DocumentReference documentRef = await wasteRef.add(waste.toMap()); 
waste.id = documentRef.documentID; 
print("uploaded waste successfully: ${waste.toString()}"); 
await documentRef.setData(waste.toMap(), merge: true); 
}

}

错误如下-

E/StorageUtil(6584(:获取令牌java.util.concurrent.ExecutionException:b.a.d.p.d.a:请在尝试获取令牌之前登录。W/NetworkRequest(6584(:请求没有身份验证令牌

检查所有这些

1( 更新到最新的依赖关系版本后,请确保推送通知仍按预期工作。

2( 查看Firebase安装文档。此外,请确保使用#onNewToken实现监控FCM注册令牌的生成。

3( 使用Firebase自动初始化过程和Gradle插件将google-services.json转换为资源的应用程序不受影响。但是,创建自己的FirebaseOptions实例的应用程序必须提供有效的API密钥、Firebase项目ID和应用程序ID。

最新更新