Skip to content

Commit 1a86ee6

Browse files
committed
Working on docs
1 parent 145eee6 commit 1a86ee6

File tree

5 files changed

+126
-30
lines changed

5 files changed

+126
-30
lines changed

README.md

Lines changed: 76 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,91 @@
1-
<!--
2-
This README describes the package. If you publish this package to pub.dev,
3-
this README's contents appear on the landing page for your package.
1+
# Firebase UI OAuth OIDC
42

5-
For information about how to write a good package README, see the guide for
6-
[writing package pages](https://dart.dev/guides/libraries/writing-package-pages).
3+
[![pub package](https://img.shields.io/pub/v/firebase_ui_oauth_oidc.svg)](https://pub.dev/packages/firebase_ui_oauth_oidc)
74

8-
For general information about developing packages, see the Dart guide for
9-
[creating packages](https://dart.dev/guides/libraries/create-library-packages)
10-
and the Flutter guide for
11-
[developing packages and plugins](https://flutter.dev/developing-packages).
12-
-->
5+
OIDC Sign In for [Firebase UI Auth](https://pub.dev/packages/firebase_ui_auth)
136

14-
TODO: Put a short description of the package here that helps potential users
15-
know whether this package might be useful for them.
7+
## Installation
168

17-
## Features
9+
Add dependency
1810

19-
TODO: List what your package can do. Maybe include images, gifs, or videos.
11+
```sh
12+
flutter pub add firebase_ui_auth
13+
flutter pub add firebase_ui_oauth_oidc
2014

21-
## Getting started
15+
flutter pub global activate flutterfire_cli
16+
flutterfire configure
17+
```
2218

23-
TODO: List prerequisites and provide or point to information on how to
24-
start using the package.
19+
Enable OIDC provider on [firebase console](https://console.firebase.google.com/).
2520

2621
## Usage
2722

28-
TODO: Include short and useful examples for package users. Add longer examples
29-
to `/example` folder.
23+
```dart
24+
import 'package:firebase_core/firebase_core.dart';
25+
import 'package:firebase_ui_auth/firebase_ui_auth.dart';
26+
import 'package:firebase_ui_oauth_apple/firebase_ui_oauth_oidc.dart';
27+
28+
void main() {
29+
WidgetsFlutterBinding.ensureInitialized();
30+
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
31+
32+
FirebaseUIAuth.configureProviders([
33+
AppleProvider(),
34+
]);
35+
36+
runApp(MyApp());
37+
}
38+
39+
class MyApp extends StatelessWidget {
40+
const MyApp({Key? key}) : super(key: key);
41+
42+
@override
43+
Widget build(BuildContext context) {
44+
return MaterialApp(
45+
home: SignInScreen(
46+
actions: [
47+
AuthStateChangeAction<SignedIn>((context, state) {
48+
// redirect to other screen
49+
})
50+
],
51+
),
52+
);
53+
}
54+
}
55+
```
56+
57+
Alternatively you could use the `OAuthProviderButton`
3058

3159
```dart
32-
const like = 'sample';
60+
class MyScreen extends StatelessWidget {
61+
@override
62+
Widget build(BuildContext context) {
63+
return AuthStateListener<OAuthController>(
64+
listener: (oldState, newState, controller) {
65+
if (newState is SignedIn) {
66+
// navigate to other screen.
67+
}
68+
},
69+
child: OAuthProviderButton(
70+
provider: AppleProvider(),
71+
),
72+
);
73+
}
74+
}
3375
```
3476

35-
## Additional information
77+
Also there is a standalone version of the `AppleSignInButton`
3678

37-
TODO: Tell users more about the package: where to find more information, how to
38-
contribute to the package, how to file issues, what response they can expect
39-
from the package authors, and more.
79+
```dart
80+
class MyScreen extends StatelessWidget {
81+
@override
82+
Widget build(BuildContext context) {
83+
return AppleSignInButton(
84+
loadingIndicator: CircularProgressIndicator(),
85+
onSignedIn: (UserCredential credential) {
86+
// perform navigation.
87+
}
88+
);
89+
}
90+
}
91+
```

pubspec.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,12 @@ packages:
107107
source: hosted
108108
version: "5.1.1"
109109
firebase_core:
110-
dependency: transitive
110+
dependency: "direct dev"
111111
description:
112112
name: firebase_core
113113
url: "https://pub.dartlang.org"
114114
source: hosted
115-
version: "2.1.1"
115+
version: "2.3.0"
116116
firebase_core_platform_interface:
117117
dependency: transitive
118118
description:
@@ -158,9 +158,9 @@ packages:
158158
firebase_ui_oauth:
159159
dependency: "direct main"
160160
description:
161-
path: "../flutterfire/packages/firebase_ui_oauth"
162-
relative: true
163-
source: path
161+
name: firebase_ui_oauth
162+
url: "https://pub.dartlang.org"
163+
source: hosted
164164
version: "1.0.4"
165165
flutter:
166166
dependency: "direct main"

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ dev_dependencies:
1919
sdk: flutter
2020

2121
rexios_lints: ^4.0.0
22-
22+
firebase_core: ^2.3.0

readme/firebase_options.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import 'package:firebase_core/firebase_core.dart';
2+
3+
class DefaultFirebaseOptions {
4+
static FirebaseOptions get currentPlatform => const FirebaseOptions(
5+
apiKey: '',
6+
appId: '',
7+
messagingSenderId: '',
8+
projectId: '',
9+
);
10+
}

readme/usage.dart

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import 'package:firebase_core/firebase_core.dart';
2+
import 'package:firebase_ui_auth/firebase_ui_auth.dart';
3+
import 'package:firebase_ui_oauth_oidc/firebase_ui_oauth_oidc.dart';
4+
import 'package:flutter/material.dart';
5+
6+
import 'firebase_options.dart';
7+
8+
void main() async {
9+
WidgetsFlutterBinding.ensureInitialized();
10+
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
11+
12+
FirebaseUIAuth.configureProviders([
13+
OidcProvider(providerId: 'oidc.example', style: ),
14+
]);
15+
16+
runApp(const MyApp());
17+
}
18+
19+
class MyApp extends StatelessWidget {
20+
const MyApp({Key? key}) : super(key: key);
21+
22+
@override
23+
Widget build(BuildContext context) {
24+
return MaterialApp(
25+
home: SignInScreen(
26+
actions: [
27+
AuthStateChangeAction<SignedIn>((context, state) {
28+
// redirect to other screen
29+
})
30+
],
31+
),
32+
);
33+
}
34+
}

0 commit comments

Comments
 (0)