Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breaking changes with latest Firebase Auth update #2

Closed
CHR15TOV opened this issue Aug 21, 2020 · 12 comments
Closed

Breaking changes with latest Firebase Auth update #2

CHR15TOV opened this issue Aug 21, 2020 · 12 comments

Comments

@CHR15TOV
Copy link

Hey Jeff,
Thanks for sharing your work and all was working well until Tuesday!
There are breaking changes with the newest version of Firebase Auth released a few days ago. I've managed to solve the other problems and just this one remains.

in the auth_controller.dart file you declare
final FirebaseAuth _auth = FirebaseAuth.instance;
and the getter
Future<User> get getUser => _auth.currentUser(); <===== this changed from <FirebaseUser> to just <User>
and
Stream<User> get user => _auth.authStateChanges(); <===== this changed from _auth.onAuthStateChanged()

the currentUser method has changed and this now fails due to 'the expression doesn't evaluate to a function, so it can't be invoked.'

BREAKING: Accessing the current user via currentUser() is now synchronous via the currentUser getter is the problem

I've updated the main.dart file to look like this:
Future main() async {
WidgetsFlutterBinding.ensureInitialized();
Get.put(AuthController());
Get.put(ThemeController());
Get.put(LanguageController());
await Firebase.initializeApp(); <===== added to ensure that Firebase is initialized prior to runApp
await GetStorage.init();
runApp(MyApp());
}

Any thoughts on how to fix this synchronous issue ?
Thanks C

@delay
Copy link
Owner

delay commented Aug 22, 2020

Thanks for letting me know about this trouble... I will try and take a look at it in the next couple of days and see if I can figure a solution. Currently finishing work on another project and should have some free time after that. Let me know if you make any progress on it in the meantime.

@delay
Copy link
Owner

delay commented Aug 23, 2020

I think I fixed the problems... Let me know if you notice any trouble. They changed a lot with the api!

@CHR15TOV
Copy link
Author

Yeah, they made a lot of what look like unnecessary and potentially conflicting name changes but understand why it makes sense to initialize at the start and changing the synchronicity methods. I'll test out your revisions as it makes your code completely up to date with the latest Firebase integration rather than having to regress to a previous working version and close the issue once we're happy with the results. With the increasing popularity of GetX you would get swamped by breaking change notices and spend too much time firefighting non-issues which is what's happening to the author Jonny!
Thanks
C

@delay
Copy link
Owner

delay commented Aug 23, 2020

Yeah I was ok with most of the changes they made and understand the rational. Hopefully they did it all at once so I am not having to come back and change things in a few months. The only change I saw that I didn't like was the change to User model instead of FirebaseUser. I think they should of kept it FirebaseUser. Kind of surprising since they added Firebase to many other calls, that made sense to me... anyway please let me know if you have any trouble with the changes made. In my short testing everything seemed to work fine...

@christheoalex
Copy link

Seems as there are still problems. Sign up is not possible with a fresh firestore connection.

@delay
Copy link
Owner

delay commented Sep 9, 2020

What error message are you receiving?

@CHR15TOV
Copy link
Author

Might be the change to the onClose() method in the auth_controller which changed recently:

Changed mine to:

@override
  Future<void> onClose() async {                                        //  dispose of controllers
    nameController?.dispose();
    emailController?.dispose();
    passwordController?.dispose();
    super.onClose();
  }

@delay
Copy link
Owner

delay commented Sep 10, 2020

Thanks, yes I saw this change as well. I haven't changed it yet as I saw a pull request that looked like it was going to put it back to the old way so was waiting to see if that was going to happen or not. I probably need to go ahead and switch it in the meantime though depending on if it isn't changed back... Thanks for the comment and code fix!

@delay
Copy link
Owner

delay commented Sep 10, 2020

I am in the process of updating... I think this has been reverted in 3.10.1 but having trouble with get_storage which is currently broken. It is currently being updated. So as soon as there is a new version, I will update the package with necessary changes. jonataslaw/get_storage#22

@christheoalex
Copy link

There was an update method used within the signup call, but the document wasn't created beforehand. I've just replaced it with set.

@jonataslaw
Copy link

Hi Jeff, I updated Get and GetStorage
GetStorage working,
onClose accept "void" and "Future" now

@delay
Copy link
Owner

delay commented Sep 10, 2020

Thanks I updated to the latest packages. I also fixed the problem with creating a new account. @christheoalex thanks for the info. I made a new function _createUserFirestore for the firestore set because I need to use the _updateUserFirestore in another function if the user changes his info. I think I didn't double check when Firestore made all of there api changes a few weeks ago and I broke the registration on that update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants