Files
Sriraj d63f4147a9 New Example - Firebase Google Authentication (#106)
* Added the firebase+google_authentication example

* Modified Readme.md
2022-10-22 20:32:53 +02:00

65 lines
2.0 KiB
Dart

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
),
),
],
)
],
),
),
);
}
}