Skip to content

Instantly share code, notes, and snippets.

// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(user!.email!),
Text(user!.displayName!),
CircleAvatar(
backgroundImage: NetworkImage(user!.photoURL!),
radius: 20,
)
class FirebaseService {
final FirebaseAuth _auth = FirebaseAuth.instance;
final GoogleSignIn _googleSignIn = GoogleSignIn();
Future<String?> signInwithGoogle() async {
try {
final GoogleSignInAccount? googleSignInAccount =
await _googleSignIn.signIn();
final GoogleSignInAuthentication googleSignInAuthentication =
await googleSignInAccount!.authentication;
void showMessage(String message) {
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: Text("Error"),
content: Text(message),
actions: [
TextButton(
child: Text("Ok"),
class GoogleSignIn extends StatefulWidget {
GoogleSignIn({Key? key}) : super(key: key);
@override
_GoogleSignInState createState() => _GoogleSignInState();
}
class _GoogleSignInState extends State<GoogleSignIn> {
bool isLoading = false;
class SignInPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
Size size = MediaQuery.of(context).size;
OutlineInputBorder border = OutlineInputBorder(
borderSide: BorderSide(color: Constants.kBorderColor, width: 3.0));
return Scaffold(
resizeToAvoidBottomInset: false,
backgroundColor: Constants.kPrimaryColor,
body: Center(
onPressed: () {
result == null
? Navigator.pushNamed(
context, Constants.signInNavigate)
: Navigator.pushReplacementNamed(
context, Constants.homeNavigate);
},
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.asset("assets/images/main-img.png"),
RichText(
textAlign: TextAlign.center,
text: TextSpan(children: <TextSpan>[
TextSpan(
text: Constants.textIntro,
style: TextStyle(
static const statusBarColor = SystemUiOverlayStyle(
statusBarColor: Constants.kPrimaryColor,
statusBarIconBrightness: Brightness.dark);
class WelcomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
Size size = MediaQuery.of(context).size;
User? result = FirebaseAuth.instance.currentUser;
return Scaffold(
backgroundColor: Constants.kPrimaryColor,
body: AnnotatedRegion<SystemUiOverlayStyle>(
value: Constants.statusBarColor,
child: Center(