aggiunto schermate login e register

This commit is contained in:
saphi
2023-09-28 13:38:12 +02:00
parent e0a8559cd1
commit 11b10b7587
8 changed files with 344 additions and 7 deletions

45
lib/pages/LoginView.dart Normal file
View File

@@ -0,0 +1,45 @@
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:google_sign_in/google_sign_in.dart';
class LoginView extends StatefulWidget {
const LoginView({super.key});
@override
State<LoginView> createState() => _LoginViewState();
}
class _LoginViewState extends State<LoginView> {
Future<UserCredential> signInWithGoogle() async {
// Trigger the authentication flow
final GoogleSignInAccount? googleUser = await GoogleSignIn().signIn();
// Obtain the auth details from the request
final GoogleSignInAuthentication? googleAuth = await googleUser?.authentication;
// Create a new credential
final credential = GoogleAuthProvider.credential(
accessToken: googleAuth?.accessToken,
idToken: googleAuth?.idToken,
);
// Once signed in, return the UserCredential
return await FirebaseAuth.instance.signInWithCredential(credential);
}
@override
void initState() {
signInWithGoogle().then((value) => print(value));
super.initState();
}
@override
Widget build(BuildContext context) {
return const Scaffold(
body: Center(
child: Icon(Icons.login)
)
);
}
}