Skip to content

Commit

Permalink
fix(firebase_ui_oauth): Fix provider auth listener late init exception (
Browse files Browse the repository at this point in the history
#107)

* Store the provider in the state so that it doesn't get reset

* Set isLoading to false in onError callback

* drop tests folder

---------

Co-authored-by: Andrei Lesnitsky <[email protected]>
  • Loading branch information
Rexios80 and lesnitsky authored Sep 12, 2023
1 parent a1c1c33 commit 0f0fa80
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
12 changes: 0 additions & 12 deletions packages/firebase_ui_oauth/example/test/widget_test.dart

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,18 @@ class OAuthProviderButtonBase extends StatefulWidget {

class _OAuthProviderButtonBaseState extends State<OAuthProviderButtonBase>
implements OAuthListener {
@override
late final OAuthProvider provider = widget.provider;

double get _height => widget.size + widget._padding * 2;
late bool isLoading = widget.isLoading;

@override
void initState() {
super.initState();

widget.provider.auth = widget.auth ?? FirebaseAuth.instance;
widget.provider.authListener = this;
provider.auth = widget.auth ?? FirebaseAuth.instance;
provider.authListener = this;
}

void _signIn() {
Expand Down Expand Up @@ -336,6 +339,10 @@ class _OAuthProviderButtonBaseState extends State<OAuthProviderButtonBase>

@override
void onError(Object error) {
setState(() {
isLoading = false;
});

try {
defaultOnAuthError(provider, error);
} on Exception catch (err) {
Expand All @@ -360,9 +367,6 @@ class _OAuthProviderButtonBaseState extends State<OAuthProviderButtonBase>

super.didUpdateWidget(oldWidget);
}

@override
OAuthProvider get provider => widget.provider;
}

class _ButtonContent extends StatelessWidget {
Expand Down

0 comments on commit 0f0fa80

Please sign in to comment.