mirror of
https://github.com/nisrulz/flutter-examples.git
synced 2026-05-14 10:47:31 +00:00
New Example - Firebase Google Authentication (#106)
* Added the firebase+google_authentication example * Modified Readme.md
This commit is contained in:
64
firebase_google_authentication/lib/Screens/InfoPage.dart
Normal file
64
firebase_google_authentication/lib/Screens/InfoPage.dart
Normal file
@@ -0,0 +1,64 @@
|
||||
import 'package:firebase_auth/firebase_auth.dart';
|
||||
import 'package:firebase_google_authentication/Services/google_auth.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class InfoPage extends StatefulWidget {
|
||||
const InfoPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_InfoPageState createState() => _InfoPageState();
|
||||
}
|
||||
|
||||
class _InfoPageState extends State<InfoPage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
User? user = FirebaseAuth.instance.currentUser;
|
||||
return SafeArea(
|
||||
child: Scaffold(
|
||||
body: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
FlatButton(onPressed: (){
|
||||
final provider = Provider.of<GoogleSignInProvider>(
|
||||
context,
|
||||
listen: false);
|
||||
provider.googleLogout();
|
||||
},
|
||||
child: Text('Logout',
|
||||
style: TextStyle(
|
||||
color: Colors.blue,
|
||||
fontSize: 16,
|
||||
),
|
||||
)),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 200,),
|
||||
Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
//crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
CircleAvatar(
|
||||
radius: 40,
|
||||
backgroundImage: NetworkImage(
|
||||
user!.photoURL??'https://cdn.pixabay.com/photo/2015/10/05/22/37/blank-profile-picture-973460_1280.png'
|
||||
),
|
||||
),
|
||||
SizedBox(height: 15,),
|
||||
Text(user!.email??'',
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w500
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user