在那里我可以找到Firebase(.firebaserc)文件AngularDart项目。
Writing configuration info to firebase.json... Writing project information to .firebaserc...
firebase错误
(anonymous function) Uncaught Unhandled exception: EXCEPTION: Error in package:my_app/views/app_component/app_component.html:0:0 ORIGINAL EXCEPTION: NoSuchMethodError: Class 'String' has no instance method '_hasProperty'. Receiver: "[DEFAULT]: Firebase: Firebase App named '[DEFAULT]' already exists (app/duplicate-app)." Tried calling: _hasProperty("message")
它包含初始化firebase的代码。
import 'dart:async'; import 'package:angular/angular.dart'; import 'package:firebase/firebase.dart' as fb; @Injectable() class FirebaseService { fb.User user; fb.Auth _fbAuth; fb.GoogleAuthProvider _fbGoogleAuthProvider; FirebaseService() { fb.initializeApp( apiKey: "AIzaSyBOShlCgUeqTL99n32bjWdNlkH1111111", authDomain: "my-app.firebaseapp.com", databaseURL: "https://my-app.firebaseio.com", storageBucket: "my-app.appspot.com", ); _fbGoogleAuthProvider = new fb.GoogleAuthProvider(); _fbAuth = fb.auth(); _fbAuth.onAuthStateChanged.listen(_authChanged); } void _authChanged(fb.User event) { user = event; } Future signIn() async { try { await _fbAuth.signInWithPopup(_fbGoogleAuthProvider); } catch (error) { print("$runtimeType::login() -- $error"); } } void signOut() { _fbAuth.signOut(); } }
如果服务中的代码只应实例化一次,请确保只提供一次服务。
只有 在里面
bootstrap(AppComponent, [...])
或者 只有
@Component( ..., providers: const [...]) } class AppComponent {}