This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>[ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void signOut() async { | |
await firebaseAuth.signOut().then((value) => { | |
setState(() { | |
user = null; | |
}) | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void signInWithGitHub() async { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Replace these values with your own ID and secret | |
static const String CLIENT_ID = "9aeb8b9d963e8b4b29e7"; | |
static const String CLIENT_SECRET = "1a00abf9c7b58d7807b6af81879db628fad945d5"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
StreamSubscription deepLinkSubscription; | |
@override | |
void initState() { | |
deepLinkSubscription = getLinksStream().listen((String link) { | |
String code = getCodeFromGitHubLink(link); | |
}, cancelOnError: true); | |
super.initState(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@override | |
void initState() { | |
deepLinkSubscription = getLinksStream().listen((String link) { | |
String code = getCodeFromGitHubLink(link); | |
loginWithGitHub(code); | |
}, cancelOnError: true); | |
super.initState(); | |
} |
OlderNewer