Skip to content

Commit

Permalink
fix: Update Provider to OAuthProvider to make it compatible to supaba…
Browse files Browse the repository at this point in the history
…se_flutter v2 (#58)

* fix: update Provider to OAuthProvider

* fix async gap analyzer issue
  • Loading branch information
dshukertjr authored Dec 17, 2023
1 parent 6203cf4 commit 9519f63
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 29 deletions.
2 changes: 0 additions & 2 deletions example/macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@ import Foundation
import app_links
import path_provider_foundation
import shared_preferences_foundation
import sign_in_with_apple
import url_launcher_macos

func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
AppLinksMacosPlugin.register(with: registry.registrar(forPlugin: "AppLinksMacosPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
SignInWithApplePlugin.register(with: registry.registrar(forPlugin: "SignInWithApplePlugin"))
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
}
6 changes: 3 additions & 3 deletions lib/src/components/supa_email_auth.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class MetaDataField {
/// },
/// ),
/// ```
/// /// {@endtemplate}
/// {@endtemplate}
class SupaEmailAuth extends StatefulWidget {
/// The URL to redirect the user to when clicking on the link on the
/// confirmation link after signing up.
Expand Down Expand Up @@ -213,13 +213,13 @@ class _SupaEmailAuthState extends State<SupaEmailAuth> {
widget.onSignUpComplete.call(response);
}
} on AuthException catch (error) {
if (widget.onError == null) {
if (widget.onError == null && context.mounted) {
context.showErrorSnackBar(error.message);
} else {
widget.onError?.call(error);
}
} catch (error) {
if (widget.onError == null) {
if (widget.onError == null && context.mounted) {
context.showErrorSnackBar(
'Unexpected error has occurred: $error');
} else {
Expand Down
4 changes: 2 additions & 2 deletions lib/src/components/supa_magic_auth.dart
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,13 @@ class _SupaMagicAuthState extends State<SupaMagicAuth> {
context.showSnackBar('Check your email inbox!');
}
} on AuthException catch (error) {
if (widget.onError == null) {
if (widget.onError == null && context.mounted) {
context.showErrorSnackBar(error.message);
} else {
widget.onError?.call(error);
}
} catch (error) {
if (widget.onError == null) {
if (widget.onError == null && context.mounted) {
context.showErrorSnackBar(
'Unexpected error has occurred: $error');
} else {
Expand Down
4 changes: 2 additions & 2 deletions lib/src/components/supa_phone_auth.dart
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,13 @@ class _SupaPhoneAuthState extends State<SupaPhoneAuth> {
widget.onSuccess(response);
}
} on AuthException catch (error) {
if (widget.onError == null) {
if (widget.onError == null && context.mounted) {
context.showErrorSnackBar(error.message);
} else {
widget.onError?.call(error);
}
} catch (error) {
if (widget.onError == null) {
if (widget.onError == null && context.mounted) {
context.showErrorSnackBar(
'Unexpected error has occurred: $error');
} else {
Expand Down
6 changes: 3 additions & 3 deletions lib/src/components/supa_reset_password.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:flutter/material.dart';
import 'package:supabase_flutter/supabase_flutter.dart';
import 'package:supabase_auth_ui/src/utils/constants.dart';
import 'package:supabase_flutter/supabase_flutter.dart';

/// UI component to create password reset form
class SupaResetPassword extends StatefulWidget {
Expand Down Expand Up @@ -72,13 +72,13 @@ class _SupaResetPasswordState extends State<SupaResetPassword> {
);
widget.onSuccess.call(response);
} on AuthException catch (error) {
if (widget.onError == null) {
if (widget.onError == null && context.mounted) {
context.showErrorSnackBar(error.message);
} else {
widget.onError?.call(error);
}
} catch (error) {
if (widget.onError == null) {
if (widget.onError == null && context.mounted) {
context.showErrorSnackBar(
'Unexpected error has occurred: $error');
} else {
Expand Down
30 changes: 15 additions & 15 deletions lib/src/components/supa_socials_auth.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,62 +10,62 @@ enum SocialProviders {
apple(
iconData: FontAwesomeIcons.apple,
btnBgColor: Colors.black,
provider: Provider.apple,
provider: OAuthProvider.apple,
),
azure(
iconData: FontAwesomeIcons.microsoft,
btnBgColor: Colors.blueAccent,
provider: Provider.azure,
provider: OAuthProvider.azure,
),
bitbucket(
iconData: FontAwesomeIcons.bitbucket,
btnBgColor: Colors.blue,
provider: Provider.bitbucket,
provider: OAuthProvider.bitbucket,
),
discord(
iconData: FontAwesomeIcons.discord,
btnBgColor: Colors.purple,
provider: Provider.discord,
provider: OAuthProvider.discord,
),
facebook(
iconData: FontAwesomeIcons.facebook,
btnBgColor: Color(0xFF3b5998),
provider: Provider.facebook,
provider: OAuthProvider.facebook,
),
github(
iconData: FontAwesomeIcons.github,
btnBgColor: Colors.black,
provider: Provider.github,
provider: OAuthProvider.github,
),
gitlab(
iconData: FontAwesomeIcons.gitlab,
btnBgColor: Colors.deepOrange,
provider: Provider.gitlab,
provider: OAuthProvider.gitlab,
),
google(
iconData: FontAwesomeIcons.google,
btnBgColor: Colors.white,
provider: Provider.google,
provider: OAuthProvider.google,
),
slack(
iconData: FontAwesomeIcons.slack,
btnBgColor: Colors.deepPurple,
provider: Provider.slack,
provider: OAuthProvider.slack,
),
spotify(
iconData: FontAwesomeIcons.spotify,
btnBgColor: Colors.green,
provider: Provider.spotify,
provider: OAuthProvider.spotify,
),
twitch(
iconData: FontAwesomeIcons.twitch,
btnBgColor: Colors.purpleAccent,
provider: Provider.twitch,
provider: OAuthProvider.twitch,
),
twitter(
iconData: FontAwesomeIcons.twitter,
btnBgColor: Color(0xFF1DA1F2),
provider: Provider.twitter,
provider: OAuthProvider.twitter,
);

const SocialProviders({
Expand All @@ -77,7 +77,7 @@ enum SocialProviders {

final IconData _iconData;
final Color _btnBgColor;
final Provider provider;
final OAuthProvider provider;

String get capitalizedName => name[0].toUpperCase() + name.substring(1);
}
Expand Down Expand Up @@ -205,13 +205,13 @@ class _SupaSocialsAuthState extends State<SupaSocialsAuth> {
redirectTo: widget.redirectUrl,
);
} on AuthException catch (error) {
if (widget.onError == null) {
if (widget.onError == null && context.mounted) {
context.showErrorSnackBar(error.message);
} else {
widget.onError?.call(error);
}
} catch (error) {
if (widget.onError == null) {
if (widget.onError == null && context.mounted) {
context
.showErrorSnackBar('Unexpected error has occurred: $error');
} else {
Expand Down
4 changes: 2 additions & 2 deletions lib/src/components/supa_verify_phone.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ class _SupaVerifyPhoneState extends State<SupaVerifyPhone> {
);
widget.onSuccess(response);
} on AuthException catch (error) {
if (widget.onError == null) {
if (widget.onError == null && context.mounted) {
context.showErrorSnackBar(error.message);
} else {
widget.onError?.call(error);
}
} catch (error) {
if (widget.onError == null) {
if (widget.onError == null && context.mounted) {
context.showErrorSnackBar(
'Unexpected error has occurred: $error');
} else {
Expand Down

0 comments on commit 9519f63

Please sign in to comment.