google_one_tap_sign_in 0.1.1 google_one_tap_sign_in: ^0.1.1 copied to clipboard
Google One Tap Sign In (Android)
/// createdby Daewu Bintara
/// Tuesday, 04/01/22 18:29
/// Enjoy coding ☕
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:google_one_tap_sign_in/google_one_tap_sign_in.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
// Your Web Client Id
final String _webClientId = "[YOUR-WEB-CLIENT-ID]";
File? _image;
@override
void initState() {
super.initState();
print("INIT STATE");
}
/// On Sign In
void _onSignIn() async {
var data = await GoogleOneTapSignIn.startSignIn(webClientId: _webClientId);
if (data != null) {
/// Whatever you do with [SignInResult] data
print("Id Token : ${data.idToken ?? "-"}");
print("ID : ${data.id ?? "-"}");
}
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Google One Tap Sign In'),
),
body: Center(
child: ListView(
shrinkWrap: true,
children: [
TextButton(
child: const Text("Sign In"),
onPressed: () => _onSignIn(),
),
],
),
),
),
);
}
}