diff --git a/example/android/.project b/example/android/.project
new file mode 100644
index 0000000..c3cb91f
--- /dev/null
+++ b/example/android/.project
@@ -0,0 +1,28 @@
+
+
+ android_
+ Project android_ created by Buildship.
+
+
+
+
+ org.eclipse.buildship.core.gradleprojectbuilder
+
+
+
+
+
+ org.eclipse.buildship.core.gradleprojectnature
+
+
+
+ 1632906553098
+
+ 30
+
+ org.eclipse.core.resources.regexFilterMatcher
+ node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__
+
+
+
+
diff --git a/example/android/.settings/org.eclipse.buildship.core.prefs b/example/android/.settings/org.eclipse.buildship.core.prefs
new file mode 100644
index 0000000..7e3761d
--- /dev/null
+++ b/example/android/.settings/org.eclipse.buildship.core.prefs
@@ -0,0 +1,13 @@
+arguments=
+auto.sync=false
+build.scans.enabled=false
+connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
+connection.project.dir=
+eclipse.preferences.version=1
+gradle.user.home=
+java.home=C\:/Program Files/Java/jdk-16.0.2
+jvm.arguments=
+offline.mode=false
+override.workspace.settings=true
+show.console.view=true
+show.executions.view=true
diff --git a/example/android/app/.project b/example/android/app/.project
new file mode 100644
index 0000000..07c98d7
--- /dev/null
+++ b/example/android/app/.project
@@ -0,0 +1,28 @@
+
+
+ app
+ Project app created by Buildship.
+
+
+
+
+ org.eclipse.buildship.core.gradleprojectbuilder
+
+
+
+
+
+ org.eclipse.buildship.core.gradleprojectnature
+
+
+
+ 1636369572190
+
+ 30
+
+ org.eclipse.core.resources.regexFilterMatcher
+ node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__
+
+
+
+
diff --git a/example/android/app/.settings/org.eclipse.buildship.core.prefs b/example/android/app/.settings/org.eclipse.buildship.core.prefs
new file mode 100644
index 0000000..b1886ad
--- /dev/null
+++ b/example/android/app/.settings/org.eclipse.buildship.core.prefs
@@ -0,0 +1,2 @@
+connection.project.dir=..
+eclipse.preferences.version=1
diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle
index a18278c..02a031d 100644
--- a/example/android/app/build.gradle
+++ b/example/android/app/build.gradle
@@ -1,4 +1,4 @@
-def localProperties = new Properties()
+/* def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
@@ -8,7 +8,7 @@ if (localPropertiesFile.exists()) {
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
- throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
+ throw new FileNotFoundException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
@@ -40,7 +40,7 @@ android {
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.boilerplate"
- minSdkVersion 16
+ minSdkVersion 23
targetSdkVersion 29
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
@@ -65,3 +65,4 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
compile 'com.android.support:multidex:1.0.1'
}
+ */
\ No newline at end of file
diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml
index 5a8e91a..36172f7 100644
--- a/example/android/app/src/main/AndroidManifest.xml
+++ b/example/android/app/src/main/AndroidManifest.xml
@@ -23,10 +23,10 @@
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
-
+ /> -->
diff --git a/example/android/build.gradle b/example/android/build.gradle
index f1a4bbb..2f03ba7 100644
--- a/example/android/build.gradle
+++ b/example/android/build.gradle
@@ -1,14 +1,16 @@
buildscript {
- ext.kotlin_version = '1.3.50'
+ ext.kotlin_version = '1.5.31'
repositories {
google()
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.5.0'
+ classpath 'com.android.tools.build:gradle:7.0.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.3'
+ classpath 'com.google.firebase:firebase-crashlytics-gradle:2.7.1'
+
}
}
diff --git a/example/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties
index 296b146..51b5b90 100644
--- a/example/android/gradle/wrapper/gradle-wrapper.properties
+++ b/example/android/gradle/wrapper/gradle-wrapper.properties
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-rc-1-all.zip
diff --git a/example/lib/main.dart b/example/lib/main.dart
index 9204d34..a5e2c6b 100644
--- a/example/lib/main.dart
+++ b/example/lib/main.dart
@@ -130,7 +130,7 @@ class _MyHomePageState extends State {
class HomeScreen extends StatelessWidget {
HomeScreen({this.user});
- final FirebaseUser user;
+ final User user;
void _logout() {
signOutProviders();
@@ -162,7 +162,7 @@ class HomeScreen extends StatelessWidget {
new SizedBox(
height: 32.0,
),
- new RaisedButton(
+ new ElevatedButton(
child: new Text("DECONNEXION"), onPressed: _logout)
],
)));
diff --git a/lib/email_view.dart b/lib/email_view.dart
index bee1f93..ccb1f44 100644
--- a/lib/email_view.dart
+++ b/lib/email_view.dart
@@ -1,3 +1,5 @@
+import 'dart:async';
+
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
@@ -7,9 +9,9 @@ import 'sign_up_view.dart';
import 'utils.dart';
class EmailView extends StatefulWidget {
- final bool passwordCheck;
+ final bool? passwordCheck;
- EmailView(this.passwordCheck, {Key key}) : super(key: key);
+ EmailView(this.passwordCheck, {Key? key}) : super(key: key);
@override
_EmailViewState createState() => new _EmailViewState();
@@ -21,7 +23,7 @@ class _EmailViewState extends State {
@override
Widget build(BuildContext context) => new Scaffold(
appBar: new AppBar(
- title: new Text(FFULocalizations.of(context).welcome),
+ title: new Text(FFULocalizations.of(context).welcome!),
elevation: 4.0,
),
body: new Builder(
@@ -49,11 +51,11 @@ class _EmailViewState extends State {
alignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [
- new FlatButton(
+ new ElevatedButton(
onPressed: () => _connexion(context),
child: new Row(
children: [
- new Text(FFULocalizations.of(context).nextButtonLabel),
+ new Text(FFULocalizations.of(context).nextButtonLabel!),
],
)),
],
@@ -69,23 +71,23 @@ class _EmailViewState extends State {
try {
final FirebaseAuth auth = FirebaseAuth.instance;
List providers =
- await auth.fetchSignInMethodsForEmail( _controllerEmail.text);
+ await auth.fetchSignInMethodsForEmail(_controllerEmail.text);
print(providers);
if (providers == null || providers.isEmpty) {
- bool connected = await Navigator.of(context)
+ bool connected = await (Navigator.of(context)
.push(new MaterialPageRoute(builder: (BuildContext context) {
return new SignUpView(_controllerEmail.text, widget.passwordCheck);
- }));
+ })) as FutureOr);
if (connected) {
Navigator.pop(context);
}
} else if (providers.contains('password')) {
- bool connected = await Navigator.of(context)
+ bool connected = await (Navigator.of(context)
.push(new MaterialPageRoute(builder: (BuildContext context) {
return new PasswordView(_controllerEmail.text);
- }));
+ })) as FutureOr);
if (connected) {
Navigator.pop(context);
@@ -108,55 +110,55 @@ class _EmailViewState extends State {
context: context,
barrierDismissible: false, // user must tap button!
builder: (BuildContext context) => new AlertDialog(
- content: new SingleChildScrollView(
- child: new ListBody(
+ content: new SingleChildScrollView(
+ child: new ListBody(
+ children: [
+ new Text(FFULocalizations.of(context)
+ .allReadyEmailMessage(email, providerName)!),
+ new SizedBox(
+ height: 16.0,
+ ),
+ new Column(
+ children: providers.map((String p) {
+ return new ElevatedButton(
+ child: new Row(
+ children: [
+ new Text(_providerStringToButton(p)!),
+ ],
+ ),
+ onPressed: () {
+ Navigator.of(context).pop(p);
+ },
+ );
+ }).toList(),
+ )
+ ],
+ )),
+ actions: [
+ new TextButton(
+ child: new Row(
children: [
- new Text(FFULocalizations.of(context)
- .allReadyEmailMessage(email, providerName)),
- new SizedBox(
- height: 16.0,
- ),
- new Column(
- children: providers.map((String p) {
- return new RaisedButton(
- child: new Row(
- children: [
- new Text(_providerStringToButton(p)),
- ],
- ),
- onPressed: () {
- Navigator.of(context).pop(p);
- },
- );
- }).toList(),
- )
+ new Text(FFULocalizations.of(context).cancelButtonLabel!),
],
- )),
- actions: [
- new FlatButton(
- child: new Row(
- children: [
- new Text(FFULocalizations.of(context).cancelButtonLabel),
- ],
- ),
- onPressed: () {
- Navigator.of(context).pop('');
- },
- ),
- ],
+ ),
+ onPressed: () {
+ Navigator.of(context).pop('');
+ },
),
+ ],
+ ),
);
}
String _providersToString(List providers) {
return providers.map((String provider) {
- ProvidersTypes type = stringToProvidersType(provider);
- return providersDefinitions(context)[type]?.name;
+ ProvidersTypes? type = stringToProvidersType(provider);
+ return providersDefinitions(context)[type!]?.name;
}).join(", ");
}
- String _providerStringToButton(String provider) {
- ProvidersTypes type = stringToProvidersType(provider);
- return providersDefinitions(context)[type]?.label;
+ String? _providerStringToButton(String provider) {
+ ProvidersTypes? type = stringToProvidersType(provider);
+ return providersDefinitions(context)[type!]?.label;
}
}
diff --git a/lib/flutter_firebase_ui.dart b/lib/flutter_firebase_ui.dart
index 850e5de..6e4a0b2 100644
--- a/lib/flutter_firebase_ui.dart
+++ b/lib/flutter_firebase_ui.dart
@@ -8,7 +8,7 @@ import 'utils.dart';
class SignInScreen extends StatefulWidget {
SignInScreen(
- {Key key,
+ {Key? key,
this.title,
this.header,
this.footer,
@@ -18,25 +18,25 @@ class SignInScreen extends StatefulWidget {
this.twitterConsumerKey,
this.twitterConsumerSecret,
this.appleSignInAvailable,
- @required this.showBar,
- @required this.avoidBottomInset,
- @required this.bottomPadding,
- @required this.horizontalPadding})
+ required this.showBar,
+ required this.avoidBottomInset,
+ required this.bottomPadding,
+ required this.horizontalPadding})
: super(key: key);
- final String title;
- final Widget header;
- final Widget footer;
- final List providers;
+ final String? title;
+ final Widget? header;
+ final Widget? footer;
+ final List? providers;
final Color color;
- final bool signUpPasswordCheck;
- final String twitterConsumerKey;
- final String twitterConsumerSecret;
+ final bool? signUpPasswordCheck;
+ final String? twitterConsumerKey;
+ final String? twitterConsumerSecret;
final bool showBar;
final bool avoidBottomInset;
final double horizontalPadding;
final double bottomPadding;
- final bool appleSignInAvailable;
+ final bool? appleSignInAvailable;
@override
_SignInScreenState createState() => new _SignInScreenState();
@@ -55,7 +55,7 @@ class _SignInScreenState extends State {
Widget build(BuildContext context) => new Scaffold(
appBar: widget.showBar
? new AppBar(
- title: new Text(widget.title),
+ title: new Text(widget.title!),
elevation: 4.0,
)
: null,
@@ -75,8 +75,8 @@ class _SignInScreenState extends State {
child: LoginView(
providers: _providers,
passwordCheck: _passwordCheck,
- twitterConsumerKey: widget.twitterConsumerKey,
- twitterConsumerSecret: widget.twitterConsumerSecret,
+ /* twitterConsumerKey: widget.twitterConsumerKey,
+ twitterConsumerSecret: widget.twitterConsumerSecret, */
bottomPadding: widget.bottomPadding,
appleSignIn: widget.appleSignInAvailable)),
),
diff --git a/lib/l10n/localization.dart b/lib/l10n/localization.dart
index e2f64cb..9ba2c39 100644
--- a/lib/l10n/localization.dart
+++ b/lib/l10n/localization.dart
@@ -6,53 +6,53 @@ import 'package:flutter/material.dart';
import 'translations.dart';
class FFULocalizations {
- TranslationBundle _translationBundle;
+ late TranslationBundle _translationBundle;
FFULocalizations(Locale locale) {
_translationBundle = translationBundleForLocale(locale);
}
- String get welcome => _translationBundle.welcome;
+ String? get welcome => _translationBundle.welcome;
- String get signUpTitle => _translationBundle.signUpTitle;
+ String? get signUpTitle => _translationBundle.signUpTitle;
- String get emailLabel => _translationBundle.emailLabel;
+ String? get emailLabel => _translationBundle.emailLabel;
- String get nextButtonLabel => _translationBundle.nextButtonLabel;
+ String? get nextButtonLabel => _translationBundle.nextButtonLabel;
- String get cancelButtonLabel => _translationBundle.cancelButtonLabel;
+ String? get cancelButtonLabel => _translationBundle.cancelButtonLabel;
- String get passwordLabel => _translationBundle.passwordLabel;
- String get passwordCheckLabel => _translationBundle.passwordCheckLabel;
- String get passwordCheckError => _translationBundle.passwordCheckError;
+ String? get passwordLabel => _translationBundle.passwordLabel;
+ String? get passwordCheckLabel => _translationBundle.passwordCheckLabel;
+ String? get passwordCheckError => _translationBundle.passwordCheckError;
- String get troubleSigningInLabel => _translationBundle.troubleSigningInLabel;
+ String? get troubleSigningInLabel => _translationBundle.troubleSigningInLabel;
- String get signInLabel => _translationBundle.signInLabel;
+ String? get signInLabel => _translationBundle.signInLabel;
- String get signInTitle => _translationBundle.signInTitle;
+ String? get signInTitle => _translationBundle.signInTitle;
- String get passwordInvalidMessage =>
+ String? get passwordInvalidMessage =>
_translationBundle.passwordInvalidMessage;
- String get recoverPasswordTitle => _translationBundle.recoverPasswordTitle;
+ String? get recoverPasswordTitle => _translationBundle.recoverPasswordTitle;
- String get recoverHelpLabel => _translationBundle.recoverHelpLabel;
+ String? get recoverHelpLabel => _translationBundle.recoverHelpLabel;
- String get sendButtonLabel => _translationBundle.sendButtonLabel;
+ String? get sendButtonLabel => _translationBundle.sendButtonLabel;
- String get nameLabel => _translationBundle.nameLabel;
+ String? get nameLabel => _translationBundle.nameLabel;
- String get saveLabel => _translationBundle.saveLabel;
+ String? get saveLabel => _translationBundle.saveLabel;
- String get passwordLengthMessage => _translationBundle.passwordLengthMessage;
+ String? get passwordLengthMessage => _translationBundle.passwordLengthMessage;
- String get signInFacebook => _translationBundle.signInFacebook;
- String get signInGoogle => _translationBundle.signInGoogle;
- String get signInEmail => _translationBundle.signInEmail;
- String get signInTwitter => _translationBundle.signInTwitter;
+ String? get signInFacebook => _translationBundle.signInFacebook;
+ String? get signInGoogle => _translationBundle.signInGoogle;
+ String? get signInEmail => _translationBundle.signInEmail;
+ String? get signInTwitter => _translationBundle.signInTwitter;
- String get errorOccurred => _translationBundle.errorOccurred;
+ String? get errorOccurred => _translationBundle.errorOccurred;
static Future load(Locale locale) {
return new SynchronousFuture(
@@ -67,10 +67,10 @@ class FFULocalizations {
static const LocalizationsDelegate delegate =
const _FFULocalizationsDelegate();
- String allReadyEmailMessage(String email, String providerName) =>
+ String? allReadyEmailMessage(String email, String providerName) =>
_translationBundle.allReadyEmailMessage(email, providerName);
- String recoverDialog(String email) => _translationBundle.recoverDialog(email);
+ String? recoverDialog(String email) => _translationBundle.recoverDialog(email);
}
class _DefaultFFULocalizations extends FFULocalizations {
diff --git a/lib/l10n/translations.dart b/lib/l10n/translations.dart
index e88f4dd..cd9b67e 100644
--- a/lib/l10n/translations.dart
+++ b/lib/l10n/translations.dart
@@ -2,50 +2,50 @@ import 'dart:ui' show Locale;
class TranslationBundle {
const TranslationBundle(this.parent);
- final TranslationBundle parent;
+ final TranslationBundle? parent;
- String get welcome => parent?.welcome;
+ String? get welcome => parent?.welcome;
- String get signUpTitle => parent?.signUpTitle;
+ String? get signUpTitle => parent?.signUpTitle;
- String get emailLabel => parent?.emailLabel;
+ String? get emailLabel => parent?.emailLabel;
- String get nextButtonLabel => parent?.nextButtonLabel;
+ String? get nextButtonLabel => parent?.nextButtonLabel;
- String get cancelButtonLabel => parent?.cancelButtonLabel;
+ String? get cancelButtonLabel => parent?.cancelButtonLabel;
- String get passwordLabel => parent?.passwordLabel;
+ String? get passwordLabel => parent?.passwordLabel;
- String get passwordCheckLabel => parent?.passwordCheckLabel;
+ String? get passwordCheckLabel => parent?.passwordCheckLabel;
- String get passwordCheckError => parent?.passwordCheckError;
+ String? get passwordCheckError => parent?.passwordCheckError;
- String get troubleSigningInLabel => parent?.troubleSigningInLabel;
+ String? get troubleSigningInLabel => parent?.troubleSigningInLabel;
- String get signInLabel => parent?.signInLabel;
+ String? get signInLabel => parent?.signInLabel;
- String get signInTitle => parent?.signInTitle;
+ String? get signInTitle => parent?.signInTitle;
- String get passwordInvalidMessage => parent?.passwordInvalidMessage;
+ String? get passwordInvalidMessage => parent?.passwordInvalidMessage;
- String get recoverPasswordTitle => parent?.recoverPasswordTitle;
+ String? get recoverPasswordTitle => parent?.recoverPasswordTitle;
- String get recoverHelpLabel => parent?.recoverHelpLabel;
+ String? get recoverHelpLabel => parent?.recoverHelpLabel;
- String get sendButtonLabel => parent?.sendButtonLabel;
+ String? get sendButtonLabel => parent?.sendButtonLabel;
- String get nameLabel => parent?.nameLabel;
+ String? get nameLabel => parent?.nameLabel;
- String get saveLabel => parent?.saveLabel;
+ String? get saveLabel => parent?.saveLabel;
- String get passwordLengthMessage => parent?.passwordLengthMessage;
+ String? get passwordLengthMessage => parent?.passwordLengthMessage;
- String get signInFacebook => parent?.signInFacebook;
- String get signInGoogle => parent?.signInGoogle;
- String get signInEmail => parent?.signInEmail;
- String get signInTwitter => parent?.signInTwitter;
+ String? get signInFacebook => parent?.signInFacebook;
+ String? get signInGoogle => parent?.signInGoogle;
+ String? get signInEmail => parent?.signInEmail;
+ String? get signInTwitter => parent?.signInTwitter;
- String get errorOccurred => parent?.errorOccurred;
+ String? get errorOccurred => parent?.errorOccurred;
allReadyEmailMessage(String email, String providerName) =>
parent?.allReadyEmailMessage(email, providerName);
diff --git a/lib/login_view.dart b/lib/login_view.dart
index 705d4eb..0dc3d3b 100644
--- a/lib/login_view.dart
+++ b/lib/login_view.dart
@@ -1,29 +1,41 @@
-import 'package:apple_sign_in/apple_sign_in.dart' as Apple;
+/* import 'package:apple_sign_in/apple_sign_in.dart' as Apple; */
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_facebook_login/flutter_facebook_login.dart';
-import 'package:flutter_twitter/flutter_twitter.dart';
import 'package:google_sign_in/google_sign_in.dart';
+// import 'package:flutter_facebook_login/flutter_facebook_login.dart';
+/* import 'package:flutter_twitter/flutter_twitter.dart';
+ */ /* import 'package:google_sign_in/google_sign_in.dart'; */
+
import 'email_view.dart';
import 'utils.dart';
+GoogleSignIn _googleSignIn = GoogleSignIn(
+ // Optional clientId
+ // clientId: '479882132969-9i9aqik3jfjd7qhci1nqf0bm2g71rm1u.apps.googleusercontent.com',
+ scopes: [
+ 'email',
+ 'https://www.googleapis.com/auth/contacts.readonly',
+ ],
+);
+
class LoginView extends StatefulWidget {
final List providers;
- final bool passwordCheck;
- final String twitterConsumerKey;
- final String twitterConsumerSecret;
+ final bool? passwordCheck;
+/* final String twitterConsumerKey;
+ final String twitterConsumerSecret; */
final double bottomPadding;
- final bool appleSignIn;
+ final bool? appleSignIn;
LoginView(
- {Key key,
- @required this.providers,
+ {Key? key,
+ required this.providers,
this.passwordCheck,
- this.twitterConsumerKey,
- this.twitterConsumerSecret,
- @required this.bottomPadding,
+/* this.twitterConsumerKey,
+ this.twitterConsumerSecret, */
+ required this.bottomPadding,
this.appleSignIn})
: super(key: key);
@@ -33,12 +45,13 @@ class LoginView extends StatefulWidget {
class _LoginViewState extends State {
final FirebaseAuth _auth = FirebaseAuth.instance;
- final Future _isAvailableFuture = Apple.AppleSignIn.isAvailable();
-
- Map _buttons;
+ final facebookLogin = FacebookLogin();
+ /* final Future _isAvailableFuture = Apple.AppleSignIn.isAvailable(); */
+ /* TODO Add 3rd party logins */
+ late Map _buttons;
_handleEmailSignIn() async {
- String value = await Navigator.of(context)
+ String? value = await Navigator.of(context)
.push(new MaterialPageRoute(builder: (BuildContext context) {
return new EmailView(widget.passwordCheck);
}));
@@ -49,38 +62,47 @@ class _LoginViewState extends State {
}
_handleGoogleSignIn() async {
- GoogleSignInAccount googleUser = await googleSignIn.signIn();
- if (googleUser != null) {
- GoogleSignInAuthentication googleAuth = await googleUser.authentication;
- if (googleAuth.accessToken != null) {
- try {
- AuthCredential credential = GoogleAuthProvider.getCredential(
- idToken: googleAuth.idToken, accessToken: googleAuth.accessToken);
- UserCredential authResult = await _auth.signInWithCredential(credential);
- User user = authResult.user;
- print(user);
- } catch (e) {
- showErrorDialog(context, e.details);
+ try {
+ GoogleSignInAccount? googleUser = await _googleSignIn.signIn();
+ if (googleUser != null) {
+ GoogleSignInAuthentication googleAuth = await googleUser.authentication;
+ if (googleAuth.accessToken != null) {
+ try {
+ AuthCredential credential = GoogleAuthProvider.credential(
+ idToken: googleAuth.idToken,
+ accessToken: googleAuth.accessToken);
+ UserCredential authResult =
+ await _auth.signInWithCredential(credential);
+ User? user = authResult.user;
+ print(user);
+ } catch (e) {
+ showErrorDialog(context, e.toString());
+ }
}
}
+ } catch (error) {
+ print(error);
}
+ /* GoogleSignInAccount? googleUser = await _googleSignIn.signIn(); */
}
_handleFacebookSignin() async {
- FacebookLoginResult result = await facebookLogin.logIn(['email']);
+ /* FacebookLoginResult result = await facebookLogin.logIn(['email']);
if (result.accessToken != null) {
try {
- AuthCredential credential = FacebookAuthProvider.credential(result.accessToken.token);
- UserCredential authResult = await _auth.signInWithCredential(credential);
- User user = authResult.user;
+ AuthCredential credential =
+ FacebookAuthProvider.credential(result.accessToken.token);
+ UserCredential authResult =
+ await _auth.signInWithCredential(credential);
+ User? user = authResult.user;
print(user);
} catch (e) {
- showErrorDialog(context, e.details);
+ showErrorDialog(context, e.toString());
}
- }
+ } */
}
- _handleTwitterSignin() async {
+/* _handleTwitterSignin() async {
var twitterLogin = new TwitterLogin(
consumerKey: widget.twitterConsumerKey,
consumerSecret: widget.twitterConsumerSecret,
@@ -90,7 +112,8 @@ class _LoginViewState extends State {
switch (result.status) {
case TwitterLoginStatus.loggedIn:
- AuthCredential credential = TwitterAuthProvider.credential(accessToken:result.session.token,secret: result.session.secret);
+ AuthCredential credential = TwitterAuthProvider.credential(
+ accessToken: result.session.token, secret: result.session.secret);
await _auth.signInWithCredential(credential);
break;
case TwitterLoginStatus.cancelledByUser:
@@ -100,9 +123,9 @@ class _LoginViewState extends State {
showErrorDialog(context, result.errorMessage);
break;
}
- }
+ } */
- Future _signInWithApple({List scopes = const []}) async {
+ /* Future _signInWithApple({List scopes = const []}) async {
// 1. perform the sign-in request
final result = await Apple.AppleSignIn.performRequests(
[Apple.AppleIdRequest(requestedScopes: scopes)]);
@@ -119,9 +142,9 @@ class _LoginViewState extends State {
final authResult = await _auth.signInWithCredential(credential);
final firebaseUser = authResult.user;
if (scopes.contains(Apple.Scope.fullName)) {
- var displayName =
+ var displayName =
'${appleIdCredential.fullName.givenName} ${appleIdCredential.fullName.familyName}';
- await firebaseUser.updateProfile(displayName: displayName);
+ await firebaseUser.updateDisplayName(displayName);
}
return firebaseUser;
case Apple.AuthorizationStatus.error:
@@ -138,35 +161,35 @@ class _LoginViewState extends State {
);
}
return null;
- }
+ } */
@override
Widget build(BuildContext context) {
_buttons = {
- ProvidersTypes.apple: FutureBuilder(
- future: _isAvailableFuture,
- builder: (context, isAvailableSnapshot) {
- if (isAvailableSnapshot.hasData && isAvailableSnapshot.data) {
- return Apple.AppleSignInButton(
- style: Apple.ButtonStyle.white, // style as needed
- type: Apple.ButtonType.signIn, // style as needed
- onPressed: () =>
- _signInWithApple(scopes: [Apple.Scope.email,Apple.Scope.fullName]),
- );
- } else {
- return Container();
- }
- }),
- ProvidersTypes.facebook:
- providersDefinitions(context)[ProvidersTypes.facebook]
- .copyWith(onSelected: _handleFacebookSignin),
+ // ProvidersTypes.apple: FutureBuilder(
+ // future: _isAvailableFuture,
+ // builder: (context, isAvailableSnapshot) {
+ // if (isAvailableSnapshot.hasData && isAvailableSnapshot.data) {
+ // return Apple.AppleSignInButton(
+ // style: Apple.ButtonStyle.white, // style as needed
+ // type: Apple.ButtonType.signIn, // style as needed
+ // onPressed: () => _signInWithApple(
+ // scopes: [Apple.Scope.email, Apple.Scope.fullName]),
+ // );
+ // } else {
+ // return Container();
+ // }
+ // }),
+ // ProvidersTypes.facebook:
+ // providersDefinitions(context)[ProvidersTypes.facebook]!
+ // .copyWith(onSelected: _handleFacebookSignin),
ProvidersTypes.google:
- providersDefinitions(context)[ProvidersTypes.google]
+ providersDefinitions(context)[ProvidersTypes.google]!
.copyWith(onSelected: _handleGoogleSignIn),
- ProvidersTypes.twitter:
- providersDefinitions(context)[ProvidersTypes.twitter]
- .copyWith(onSelected: _handleTwitterSignin),
- ProvidersTypes.email: providersDefinitions(context)[ProvidersTypes.email]
+ // ProvidersTypes.twitter:
+ // providersDefinitions(context)[ProvidersTypes.twitter]
+ // .copyWith(onSelected: _handleTwitterSignin),
+ ProvidersTypes.email: providersDefinitions(context)[ProvidersTypes.email]!
.copyWith(onSelected: _handleEmailSignIn),
};
@@ -182,13 +205,13 @@ class _LoginViewState extends State {
}
void _followProvider(String value) {
- ProvidersTypes provider = stringToProvidersType(value);
+ ProvidersTypes? provider = stringToProvidersType(value);
if (provider == ProvidersTypes.facebook) {
_handleFacebookSignin();
} else if (provider == ProvidersTypes.google) {
_handleGoogleSignIn();
- } else if (provider == ProvidersTypes.twitter) {
+ } /* else if (provider == ProvidersTypes.twitter) {
_handleTwitterSignin();
- }
+ } */
}
}
diff --git a/lib/password_view.dart b/lib/password_view.dart
index 7ef3a1e..c2cf155 100644
--- a/lib/password_view.dart
+++ b/lib/password_view.dart
@@ -8,15 +8,15 @@ import 'utils.dart';
class PasswordView extends StatefulWidget {
final String email;
- PasswordView(this.email, {Key key}) : super(key: key);
+ PasswordView(this.email, {Key? key}) : super(key: key);
@override
_PasswordViewState createState() => new _PasswordViewState();
}
class _PasswordViewState extends State {
- TextEditingController _controllerEmail;
- TextEditingController _controllerPassword;
+ TextEditingController? _controllerEmail;
+ TextEditingController? _controllerPassword;
@override
initState() {
@@ -27,10 +27,10 @@ class _PasswordViewState extends State {
@override
Widget build(BuildContext context) {
- _controllerEmail.text = widget.email;
+ _controllerEmail!.text = widget.email;
return new Scaffold(
appBar: new AppBar(
- title: new Text(FFULocalizations.of(context).signInTitle),
+ title: new Text(FFULocalizations.of(context).signInTitle!),
elevation: 4.0,
),
body: new Builder(
@@ -61,7 +61,7 @@ class _PasswordViewState extends State {
alignment: Alignment.centerLeft,
child: new InkWell(
child: new Text(
- FFULocalizations.of(context).troubleSigningInLabel,
+ FFULocalizations.of(context).troubleSigningInLabel!,
style: Theme.of(context).textTheme.caption,
),
onTap: _handleLostPassword)),
@@ -75,11 +75,11 @@ class _PasswordViewState extends State {
alignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [
- new FlatButton(
+ new TextButton(
onPressed: () => _connexion(context),
child: new Row(
children: [
- new Text(FFULocalizations.of(context).signInLabel),
+ new Text(FFULocalizations.of(context).signInLabel!),//HERE
],
)),
],
@@ -95,22 +95,22 @@ class _PasswordViewState extends State {
_handleLostPassword() {
Navigator.of(context)
.push(new MaterialPageRoute(builder: (BuildContext context) {
- return new TroubleSignIn(_controllerEmail.text);
+ return new TroubleSignIn(_controllerEmail!.text);
}));
}
_connexion(BuildContext context) async {
FirebaseAuth _auth = FirebaseAuth.instance;
UserCredential authResult;
- User user;
+ User? user;
try {
authResult = await _auth.signInWithEmailAndPassword(
- email: _controllerEmail.text, password: _controllerPassword.text);
+ email: _controllerEmail!.text, password: _controllerPassword!.text);
user = authResult.user;
print(user);
} catch (exception) {
//TODO improve errors catching
- String msg = FFULocalizations.of(context).passwordInvalidMessage;
+ String? msg = FFULocalizations.of(context).passwordInvalidMessage;
showErrorDialog(context, msg);
}
diff --git a/lib/sign_up_view.dart b/lib/sign_up_view.dart
index e44962c..eb10c57 100644
--- a/lib/sign_up_view.dart
+++ b/lib/sign_up_view.dart
@@ -7,19 +7,19 @@ import 'utils.dart';
class SignUpView extends StatefulWidget {
final String email;
- final bool passwordCheck;
+ final bool? passwordCheck;
- SignUpView(this.email, this.passwordCheck, {Key key}) : super(key: key);
+ SignUpView(this.email, this.passwordCheck, {Key? key}) : super(key: key);
@override
_SignUpViewState createState() => new _SignUpViewState();
}
class _SignUpViewState extends State {
- TextEditingController _controllerEmail;
- TextEditingController _controllerDisplayName;
- TextEditingController _controllerPassword;
- TextEditingController _controllerCheckPassword;
+ TextEditingController? _controllerEmail;
+ TextEditingController? _controllerDisplayName;
+ TextEditingController? _controllerPassword;
+ TextEditingController? _controllerCheckPassword;
final FocusNode _focusPassword = FocusNode();
@@ -42,10 +42,10 @@ class _SignUpViewState extends State {
@override
Widget build(BuildContext context) {
- _controllerEmail.text = widget.email;
+ _controllerEmail!.text = widget.email;
return new Scaffold(
appBar: new AppBar(
- title: new Text(FFULocalizations.of(context).signUpTitle),
+ title: new Text(FFULocalizations.of(context).signUpTitle!),
elevation: 4.0,
),
body: new Builder(
@@ -83,7 +83,7 @@ class _SignUpViewState extends State {
decoration: new InputDecoration(
labelText: FFULocalizations.of(context).passwordLabel),
),
- !widget.passwordCheck
+ !widget.passwordCheck!
? new Container()
: new TextField(
controller: _controllerCheckPassword,
@@ -103,11 +103,11 @@ class _SignUpViewState extends State {
alignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [
- new FlatButton(
+ new TextButton(
onPressed: _valid ? () => _connexion(context) : null,
child: new Row(
children: [
- new Text(FFULocalizations.of(context).saveLabel),
+ new Text(FFULocalizations.of(context).saveLabel!),
],
)),
],
@@ -125,8 +125,8 @@ class _SignUpViewState extends State {
}
_connexion(BuildContext context) async {
- if (widget.passwordCheck &&
- _controllerPassword.text != _controllerCheckPassword.text) {
+ if (widget.passwordCheck! &&
+ _controllerPassword!.text != _controllerCheckPassword!.text) {
showErrorDialog(context, FFULocalizations.of(context).passwordCheckError);
return;
}
@@ -134,28 +134,28 @@ class _SignUpViewState extends State {
FirebaseAuth _auth = FirebaseAuth.instance;
try {
UserCredential authResult = await _auth.createUserWithEmailAndPassword(
- email: _controllerEmail.text,
- password: _controllerPassword.text,
+ email: _controllerEmail!.text,
+ password: _controllerPassword!.text,
);
- User user = authResult.user;
+ User user = authResult.user!;
try {
- var displayName = _controllerDisplayName.text;
- await user.updateProfile(displayName: displayName);
+ var displayName = _controllerDisplayName!.text;
+ await user.updateDisplayName(displayName);
Navigator.pop(context, true);
} catch (e) {
- showErrorDialog(context, e.details);
+ showErrorDialog(context, e.toString());
}
} on PlatformException catch (e) {
print(e.details);
//TODO improve errors catching
- String msg = FFULocalizations.of(context).passwordLengthMessage;
+ String? msg = FFULocalizations.of(context).passwordLengthMessage;
showErrorDialog(context, msg);
}
}
void _checkValid(String value) {
setState(() {
- _valid = _controllerDisplayName.text.isNotEmpty;
+ _valid = _controllerDisplayName!.text.isNotEmpty;
});
}
}
diff --git a/lib/trouble_signin.dart b/lib/trouble_signin.dart
index 9eaa4ee..cc133ef 100644
--- a/lib/trouble_signin.dart
+++ b/lib/trouble_signin.dart
@@ -7,14 +7,14 @@ import 'utils.dart';
class TroubleSignIn extends StatefulWidget {
final String email;
- TroubleSignIn(this.email, {Key key}) : super(key: key);
+ TroubleSignIn(this.email, {Key? key}) : super(key: key);
@override
_TroubleSignInState createState() => new _TroubleSignInState();
}
class _TroubleSignInState extends State {
- TextEditingController _controllerEmail;
+ TextEditingController? _controllerEmail;
@override
initState() {
@@ -24,10 +24,10 @@ class _TroubleSignInState extends State {
@override
Widget build(BuildContext context) {
- _controllerEmail.text = widget.email;
+ _controllerEmail!.text = widget.email;
return new Scaffold(
appBar: new AppBar(
- title: new Text(FFULocalizations.of(context).recoverPasswordTitle),
+ title: new Text(FFULocalizations.of(context).recoverPasswordTitle!),
elevation: 4.0,
),
body: new Builder(
@@ -47,7 +47,7 @@ class _TroubleSignInState extends State {
new Container(
alignment: Alignment.centerLeft,
child: new Text(
- FFULocalizations.of(context).recoverHelpLabel,
+ FFULocalizations.of(context).recoverHelpLabel!,
style: Theme.of(context).textTheme.caption,
)),
//const SizedBox(height: 5.0),
@@ -61,11 +61,11 @@ class _TroubleSignInState extends State {
alignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [
- new FlatButton(
+ new TextButton(
onPressed: () => _send(context),
child: new Row(
children: [
- new Text(FFULocalizations.of(context).sendButtonLabel),
+ new Text(FFULocalizations.of(context).sendButtonLabel!),
],
)),
],
@@ -77,13 +77,13 @@ class _TroubleSignInState extends State {
_send(BuildContext context) async {
FirebaseAuth _auth = FirebaseAuth.instance;
try {
- await _auth.sendPasswordResetEmail(email: _controllerEmail.text);
+ await _auth.sendPasswordResetEmail(email: _controllerEmail!.text);
Navigator.of(context).pop();
} catch (exception) {
- showErrorDialog(context, exception);
+ showErrorDialog(context, exception.toString());
}
showErrorDialog(context,
- FFULocalizations.of(context).recoverDialog(_controllerEmail.text));
+ FFULocalizations.of(context).recoverDialog(_controllerEmail!.text));
}
}
diff --git a/lib/utils.dart b/lib/utils.dart
index 4650fbe..33d28ec 100644
--- a/lib/utils.dart
+++ b/lib/utils.dart
@@ -4,14 +4,16 @@ import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_ui/l10n/localization.dart';
import 'package:flutter/material.dart';
import 'package:flutter_facebook_login/flutter_facebook_login.dart';
+// import 'package:flutter_facebook_login/flutter_facebook_login.dart';
import 'package:google_sign_in/google_sign_in.dart';
enum ProvidersTypes { email, google, facebook, twitter, phone, apple }
+/* TODO Add 3rd party logins */
final GoogleSignIn googleSignIn = new GoogleSignIn();
-final FacebookLogin facebookLogin = new FacebookLogin();
+// final FacebookLogin facebookLogin = new FacebookLogin();
-ProvidersTypes stringToProvidersType(String value) {
+ProvidersTypes? stringToProvidersType(String value) {
if (value.toLowerCase().contains('facebook')) return ProvidersTypes.facebook;
if (value.toLowerCase().contains('google')) return ProvidersTypes.google;
if (value.toLowerCase().contains('password')) return ProvidersTypes.email;
@@ -22,28 +24,28 @@ ProvidersTypes stringToProvidersType(String value) {
// Description button
class ButtonDescription extends StatelessWidget {
- final String label;
+ final String? label;
final Color labelColor;
final Color color;
final String logo;
final String name;
- final VoidCallback onSelected;
+ final VoidCallback? onSelected;
const ButtonDescription(
- {@required this.logo,
- @required this.label,
- @required this.name,
+ {required this.logo,
+ required this.label,
+ required this.name,
this.onSelected,
this.labelColor = Colors.grey,
this.color = Colors.white});
ButtonDescription copyWith({
- String label,
- Color labelColor,
- Color color,
- String logo,
- String name,
- VoidCallback onSelected,
+ String? label,
+ Color? labelColor,
+ Color? color,
+ String? logo,
+ String? name,
+ VoidCallback? onSelected,
}) {
return new ButtonDescription(
label: label ?? this.label,
@@ -57,8 +59,10 @@ class ButtonDescription extends StatelessWidget {
@override
Widget build(BuildContext context) {
VoidCallback _onSelected = onSelected ?? () => {};
- return new RaisedButton(
- color: color,
+ return new ElevatedButton(
+ style: ElevatedButton.styleFrom(primary: color),
+/* color: color,
+ */
child: new Row(
children: [
new Container(
@@ -66,7 +70,7 @@ class ButtonDescription extends StatelessWidget {
child: new Image.asset('assets/$logo', package: 'firebase_ui')),
new Expanded(
child: new Text(
- label,
+ label!,
style: new TextStyle(color: labelColor),
),
)
@@ -105,8 +109,8 @@ Map providersDefinitions(
labelColor: Colors.white),
};
-Future showErrorDialog(BuildContext context, String message,
- {String title}) {
+Future showErrorDialog(BuildContext context, String? message,
+ {String? title}) {
return showDialog(
context: context,
barrierDismissible: false, // user must tap button!
@@ -115,15 +119,15 @@ Future showErrorDialog(BuildContext context, String message,
content: new SingleChildScrollView(
child: new ListBody(
children: [
- new Text(message ?? FFULocalizations.of(context).errorOccurred),
+ new Text(message ?? FFULocalizations.of(context).errorOccurred!),
],
),
),
actions: [
- new FlatButton(
+ new TextButton(
child: new Row(
children: [
- new Text(FFULocalizations.of(context).cancelButtonLabel),
+ new Text(FFULocalizations.of(context).cancelButtonLabel!),
],
),
onPressed: () {
@@ -136,7 +140,7 @@ Future showErrorDialog(BuildContext context, String message,
}
Future signOutProviders() async {
- var currentUser = FirebaseAuth.instance.currentUser;
+ var currentUser = FirebaseAuth.instance.currentUser;
if (currentUser != null) {
await signOut(currentUser.providerData);
}
@@ -145,11 +149,11 @@ Future signOutProviders() async {
}
Future signOut(Iterable providers) async {
- return Future.forEach(providers, (p) async {
+ return Future.forEach(providers, (dynamic p) async {
switch (p.providerId) {
case 'facebook.com':
- await facebookLogin.logOut();
- break;
+ /* await facebookLogin.logOut();
+ break; */
case 'google.com':
await googleSignIn.signOut();
break;
diff --git a/pubspec.yaml b/pubspec.yaml
index 821ddaa..4c85a06 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,24 +1,24 @@
name: firebase_ui
description: Firebase auth UI, dart package to mimic the firebaseUI(Google,Facebook,Twitter,Email supported)
version: 1.0.8
-author: Nicholas Bowler
homepage: https://github.com/Maliffic/firebase_ui
environment:
- sdk: ">=2.7.0 <3.0.0"
+ sdk: '>=2.12.0 <3.0.0'
dependencies:
flutter:
sdk: flutter
- flutter_twitter: ^1.1.3
+ # flutter_twitter: ^1.1.3
- firebase_auth: ^0.18.2
+ firebase_auth: ^3.1.0
- google_sign_in: ^4.5.5
+ google_sign_in: ^5.2.1
+
flutter_facebook_login: ^3.0.0
- apple_sign_in: ^0.1.0
+ # apple_sign_in: ^0.1.0
dev_dependencies:
flutter_test: