exa_auth 1.0.0
exa_auth: ^1.0.0 copied to clipboard
Social login
example/lib/main.dart
// ignore_for_file: depend_on_referenced_packages
import 'dart:async';
import 'dart:convert';
import 'package:exa_auth/exa_auth.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
String getPrettyJSONString(jsonObject) {
var encoder = const JsonEncoder.withIndent(" ");
return encoder.convert(jsonObject);
}
Future main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) => MaterialApp(
debugShowCheckedModeBanner: false,
home: PhoneAuthScreen(),
);
}
class PhoneAuthScreen extends StatelessWidget {
PhoneAuthScreen({super.key});
final hideWithContainsUser = ValueNotifier(false);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Phone Authentication'),
),
body: Padding(
padding: const EdgeInsets.all(16.0),
child: ValueListenableBuilder(
valueListenable: hideWithContainsUser,
builder: (c, v, w) => ListView(
children: <Widget>[
CheckboxListTile(
value: hideWithContainsUser.value,
onChanged: (v) {
hideWithContainsUser.value = v ?? false;
},
title: Text(hideWithContainsUser.value
? 'Sumir com os botoes se logado'
: 'Nao sumir com os botoes se logado'),
),
CurrentUserAuthContainer(builder: (v, w) {
return Column(
children: [
Text(getPrettyJSONString(v?.toMap() ?? {})),
if (v != null)
ElevatedButton(
onPressed: ExaAuth.i.controller.logout,
child: const Text('SAIR'),
),
const SizedBox(
height: 8,
),
],
);
}),
AppleAuthButton(
hideWithContainsUser: hideWithContainsUser.value,
clientId: 'br.com.fshero'),
const SizedBox(
height: 15,
),
GoogleAuthButton(
hideWithContainsUser: hideWithContainsUser.value,
),
const SizedBox(
height: 15,
),
PhoneAuthButton(
hideWithContainsUser: hideWithContainsUser.value,
)
],
)),
),
);
}
}