我可以在哪里找到Firebase(.firebaserc)文件AngularDart项目。
Firebase在项目连接时写入以下文件。
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的代码。 firebase_service.dart
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();
}
}
答案 0 :(得分:0)
如果您的服务中的代码只应实例化一次,请确保您只提供一次服务。
在
中提供仅这样的服务bootstrap(AppComponent, [...])
或
中的@Component(
...,
providers: const [...])
}
class AppComponent {}