Skip to content

Instantly share code, notes, and snippets.

url_launcher: ^5.7.2
uni_links: ^0.4.0
firebase_core: ^0.5.0+1
firebase_auth: ^0.18.1+2
google_sign_in: ^4.5.4
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(MyApp());
}
class MyApp extends StatelessWidget {
class _MyHomePageState extends State<MyHomePage> {
final FirebaseAuth firebaseAuth = FirebaseAuth.instance;
UserCredential user;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
actions: <Widget>[
void signOut() async {
await firebaseAuth.signOut().then((value) => {
setState(() {
user = null;
})
});
}
void signInWithGitHub() async {
}
//Replace these values with your own ID and secret
static const String CLIENT_ID = "9aeb8b9d963e8b4b29e7";
static const String CLIENT_SECRET = "1a00abf9c7b58d7807b6af81879db628fad945d5";
void signInWithGitHub() async {
const String url = "https://github.com/login/oauth/authorize?client_id=" + CLIENT_ID
+ "&scope=user:email";
if (await canLaunch(url)) {
await launch(url);
} else {
throw "Could not launch $url";
}
}
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https"
android:host="flutterfire-ptruiz.firebaseapp.com" />
</intent-filter>
StreamSubscription deepLinkSubscription;
@override
void initState() {
deepLinkSubscription = getLinksStream().listen((String link) {
String code = getCodeFromGitHubLink(link);
}, cancelOnError: true);
super.initState();
}
@override
void initState() {
deepLinkSubscription = getLinksStream().listen((String link) {
String code = getCodeFromGitHubLink(link);
loginWithGitHub(code);
}, cancelOnError: true);
super.initState();
}