This repository has been archived by the owner on Feb 21, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.dart
70 lines (60 loc) · 1.72 KB
/
main.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// Copyright 2017, Google Inc. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:angular2/angular2.dart';
import 'package:angular2/platform/browser.dart';
import 'package:angular_fire/angular_fire.dart';
import 'package:firebase/firebase.dart' as sdk;
@AngularEntrypoint()
void main() {
bootstrap(AngularFireExample, <dynamic>[
provide(
FirebaseAuth,
useValue: new FirebaseAuth(
sdk.initializeApp(
apiKey: 'AIzaSyA717X1TrdsnUS90pUdk1FVVS2AX_S-0mE',
authDomain: 'angular-fire-dart-demo.firebaseapp.com',
databaseURL: 'https://angular-fire-dart-demo.firebaseio.com',
storageBucket: 'angular-fire-dart-demo.appspot.com',
),
),
),
]);
}
@Component(
selector: 'angular-fire-example',
directives: const <dynamic>[
IfFirebaseAuthDirective,
GoogleSignInComponent,
],
template: r'''
<div *ifFirebaseAuth="true; let currentUser = currentUser">
Logged in as: {{currentUser.displayName}}.
<button (click)="signOut()">Sign Out</button>
</div>
<div *ifFirebaseAuth="false">
Waiting for sign in...
<br>
<google-sign-in
(trigger)="signIn()">
</google-sign-in>
<google-sign-in
[useDarkTheme]="true"
(trigger)="signIn()">
</google-sign-in>
</div>
''',
preserveWhitespace: false,
)
class AngularFireExample {
final FirebaseAuth _auth;
AngularFireExample(this._auth);
void signIn() {
_auth.googleSignIn(scopes: [
'https://www.googleapis.com/auth/calendar.readonly',
]);
}
void signOut() {
_auth.signOut();
}
}