delay / flutter_starter

MIT License
422 stars 146 forks source link

Breaking changes with latest Firebase Auth update #2

Closed CHR15TOV closed 4 years ago

CHR15TOV commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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

CHR15TOV commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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

delay commented 4 years ago

What error message are you receiving?

CHR15TOV commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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. https://github.com/jonataslaw/get_storage/issues/22

christheoalex commented 4 years ago

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 commented 4 years ago

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

delay commented 4 years ago

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.