Android 方法';配置';isn';t为类型';FirebaseApp';

Android 方法';配置';isn';t为类型';FirebaseApp';,android,firebase,flutter,google-cloud-firestore,Android,Firebase,Flutter,Google Cloud Firestore,我正在使用firebase身份验证进行用户登录,但收到FirebaseApp配置方法的此错误消息。 下面是我的代码 import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/material.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:firebase_core/firebase_core.da

我正在使用firebase身份验证进行用户登录,但收到FirebaseApp配置方法的此错误消息。
下面是我的代码

import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_core/firebase_core.dart';
import '../Questions.dart';

class Tasks extends StatefulWidget {
  Tasks({this.uid: ""});
  final String uid;
  @override
  TasksState createState() => TasksState(uid);
}

class TasksState extends State<Tasks> {
  var now = DateTime.now();
  bool timeUp = true;
  TasksState(this.userId);

  Map<String, dynamic> identifiers = Map.from({
    "answered": false,
    "value": false,
    "notDone1": true,
    "notDone2": true,
    "defNumber": -1,
    "hour": null
  });
  FirebaseAuth auth = FirebaseAuth.instance;

  String userId;
  DocumentReference ansRef;

  Future<void> configure() async {
    final FirebaseApp app = await FirebaseApp.configure(
        name: 'companionbeta',
        options: const FirebaseOptions(
            googleAppID: '*******************************',
            apiKey: '********************************',
            projectID: '*******************'
));
    final FirebaseFirestore firestore = Firestore.instance();
    await firestore.settings(timestampsInSnapshotsEnabled: true);
  }

  bool isDepressed(DocumentSnapshot document) {
    document.data.putIfAbsent("q1", document["defNumber"]);
    if (document["q1"] < 3) return true;
    return false;
  }

  @override
  void initState() {
    configure();
    ansRef = Firestore.instance.collection("answers").document(userId);
    addData();
    super.initState();
  }

  void updateTime(DocumentSnapshot document) async {
    if (document["hour"] == null)
      await document.reference.updateData({"hour": now.hour});
    assert(now.hour != null);
    if (document["hour"] < 24) {
      setState(() {
        timeUp = true;
      });
      await document.reference.updateData({"hour": document["hour"] + 24});
    }
  }

  void addData() async {
    ansRef.get().then((DocumentSnapshot ds) {
      ds.data.addAll(identifiers);
      updateTime(ds);
      isDepressed(ds);
    });
  }

  @override
  Widget build(BuildContext context) {
    return Material(
        child: StreamBuilder(
            stream: Firestore.instance.collection("answers").snapshots(),
            builder: (context, snapshot) {
              if (!snapshot.hasData) return Text("Loading..");
              DocumentSnapshot doc = snapshot.data.documents[0];
              Map<String, bool> check = Map.from({
                "answered": (doc["answered"] == null) ? false : true,
                "notDone1": (doc["notDone1"] == null) ? false : true,
                "notDone2": (doc["notDone2"] == null) ? false : true,
                "q1": (doc["q1"] == null) ? false : true,
              });
              return builder(context, doc, check);
            }));
  }

  Widget builder(BuildContext context, DocumentSnapshot document,
      Map<String, bool> check) {
    return Column(mainAxisSize: MainAxisSize.min, children: <Widget>[
      (check["answered"] && timeUp && !document["answered"])
          ? askQuestion(document)
          : Container(),
      Flexible(
          child: Card(
        child: ListView(
          children: <Widget>[
            (check["notDone1"] &&
                    check["q1"] &&
                    isDepressed(document) &&
                    document["notDone1"])
                ? ListTile(
                    contentPadding: EdgeInsets.all(10.0),
                    leading: Icon(Icons.people),
                    title: Text("Meet more people"),
                    subtitle: Text("uno dos tres"),
                    trailing: Checkbox(
                      value: false,
                      onChanged: (value) {
                        setState(() {
                          if (value)
                            document.reference.updateData({"notDone1": false});
                        });
                      },
                    ),
                  )
                : Container(),
            (check["notDone2"] &&
                    check["q1"] &&
                    isDepressed(document) &&
                    document["notDone2"])
                ? ListTile(
                    contentPadding: EdgeInsets.symmetric(horizontal: 10.0),
                    leading: Icon(Icons.library_music),
                    title: Text("Listen to tunes"),
                    subtitle: Text("uno dos tres"),
                    trailing: Checkbox(
                      value: document["value"],
                      onChanged: (value) {
                        setState(() {
                          if (value)
                            document.reference.updateData({"notDone2": false});
                        });
                      },
                    ),
                  )
                : Container(),
            (check["q1"] &&
                    check["notDone1"] &&
                    isDepressed(document) &&
                    !document["notDone1"])
                ? Card(
                    child: Expanded(
                    child: Text("Yay! We are happy today"),
                  ))
                : Container()
          ],
        ),
        elevation: 2.0,
        margin: EdgeInsets.symmetric(horizontal: 12.0, vertical: 6.0),
      ))
    ]);
  }

  Widget askQuestion(DocumentSnapshot document) {
    return Card(
      child: Column(
        mainAxisSize: MainAxisSize.min,
        children: <Widget>[
          const ListTile(
            leading: Icon(Icons.question_answer),
            title: Text('Ready to answer a few questions?'),
            subtitle: Text('It will only take a minute'),
          ),
          ButtonTheme.bar(
            // make buttons use the appropriate styles for cards
            child: ButtonBar(
              children: <Widget>[
                FlatButton(
                  child: const Text('Yes!'),
                  onPressed: () {
                    Navigator.of(context).push(MaterialPageRoute(
                        builder: (context) => Questions(document)));
                  },
                ),
                FlatButton(
                  child: const Text('Not now'),
                  onPressed: () {
                    setState(() {
                      document.reference.updateData({"answered": true});
                    });
                  },
                ),
              ],
            ),
          ),
        ],
      ),
      elevation: 2.0,
      margin: EdgeInsets.all(12.0),
    );
  }
}

import'package:firebase_auth/firebase_auth.dart';
进口“包装:颤振/材料.省道”;
导入“包:cloud_firestore/cloud_firestore.dart”;
导入“包:firebase_core/firebase_core.dart”;
导入“../Questions.dart”;
类任务扩展StatefulWidget{
任务({this.uid:”“});
最后一个字符串uid;
@凌驾
TasksState createState()=>TasksState(uid);
}
类TasksState扩展状态{
var now=DateTime.now();
bool timeUp=true;
TasksState(this.userId);
映射标识符=Map.from({
回答:错,
“值”:假,
“notDone1”:正确,
“notDone2”:正确,
“defNumber”:-1,
“小时”:空
});
FirebaseAuth auth=FirebaseAuth.instance;
字符串用户标识;
文件参考ansRef;
Future configure()异步{
final FirebaseApp app=等待FirebaseApp.configure(
名称:'companionbeta',
选项:常量FirebaseOptions(
googleAppID:“**********************************************************”,
apiKey:“****************************************”,
项目D:“*********************”
));
final FirebaseFirestore firestore=firestore.instance();
等待firestore.settings(timestampsInSnapshotsEnabled:true);
}
bool已还原(文档快照文档){
文件.data.putIfAbsent(“q1”,文件[“defNumber]”);
如果(文档[“q1”]<3)返回true;
返回false;
}
@凌驾
void initState(){
configure();
ansRef=Firestore.instance.collection(“answers”).document(userId);
addData();
super.initState();
}
void updateTime(文档快照文档)异步{
如果(文档[“小时”]==null)
wait document.reference.updateData({“hour”:now.hour});
断言(now.hour!=null);
如果(文件[“小时”]<24){
设置状态(){
timeUp=true;
});
wait document.reference.updateData({“hour”:document[“hour”]+24});
}
}
void addData()异步{
ansRef.get().then((文档快照){
ds.data.addAll(标识符);
更新时间(ds);
isDepressed(ds);
});
}
@凌驾
小部件构建(构建上下文){
退货(
孩子:StreamBuilder(
流:Firestore.instance.collection(“answers”).snapshots(),
生成器:(上下文,快照){
如果(!snapshot.hasData)返回文本(“加载…”);
DocumentSnapshot doc=snapshot.data.documents[0];
Map check=Map.from({
“已回答”:(doc[“已回答”]==null)?false:true,
“notDone1”:(doc[“notDone1”]==null)?false:true,
“notDone2”:(doc[“notDone2”]==null)?false:true,
“q1”:(doc[“q1”]==null)?false:true,
});
返回生成器(上下文、文档、检查);
}));
}
小部件生成器(构建上下文上下文、文档快照文档、,
(地图检查){
返回列(mainAxisSize:mainAxisSize.min,子项:[
(检查[“已回答”]&&timeUp&!文档[“已回答”])
?询问问题(文件)
:Container(),
灵活的(
孩子:卡片(
子:ListView(
儿童:[
(勾选[“notDone1”]&&
勾选[“q1”]&&
isDepressed(文档)&&
文件[“notDone1”])
?列表磁砖(
contentPadding:EdgeInsets.all(10.0),
领先:图标(图标、人物),
标题:文本(“结识更多人”),
副标题:文本(“uno dos tres”),
尾随:复选框(
值:false,
一旦更改:(值){
设置状态(){
如果(值)
document.reference.updateData({“notDone1”:false});
});
},
),
)
:Container(),
(勾选[“notDone2”]&&
勾选[“q1”]&&
isDepressed(文档)&&
文件[“notDone2”])
?列表磁砖(
内容填充:边集。对称(水平:10.0),
前导:图标(图标、图书馆音乐),
标题:文本(“听音乐”),
副标题:文本(“uno dos tres”),
尾随:复选框(
值:文档[“值”],
一旦更改:(值){
设置状态(){
如果(值)
document.reference.updateData({“notDone2”:false});
});
},
),
)
:Container(),
(勾选[“q1”]&&
勾选[“notDone1”]&&
isDepressed(文档)&&
!文档[“notDone1”])
?卡(
儿童:扩大(
孩子:文本(“耶!我们今天很快乐”),
))
:Container()
],
),
标高:2.0,
边缘:边缘组。对称(水平:12.0,垂直:6.0),
))
]);
}
小部件询问问题(文档快照文档){
回程卡(
子:列(
mainAxisSize:mainAxisSize.min,
儿童:[
常量列表(
引导:图标(图标。问题和答案),
标题:文本(“准备好回答几个问题了吗?”),
字幕:文本(“只需一分钟”),
),
钮扣柄(
//使按钮使用适合卡片的样式
孩子:巴顿巴(
儿童:[
扁平按钮(
    final FirebaseApp app = await FirebaseApp.initializeApp(
        name: 'companionbeta',
        options: const FirebaseOptions(
            googleAppID: '*******************************',
            apiKey: '********************************',
            projectID: '*******************'
));