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

Improvement in filling of user object from database from uid @kshitijalwadhi #62

Open
tmibvishal opened this issue May 31, 2020 · 0 comments
Labels
enhancement New feature or request

Comments

@tmibvishal
Copy link
Member

assigned to @kshitijalwadhi

E/flutter (24894): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: NoSuchMethodError: The method '[]' was called on null.
E/flutter (24894): Receiver: null
E/flutter (24894): Tried calling: []("currentGroup")

This happened because of this

final currentuser = Provider.of<FirebaseUser>(context);
    Firestore.instance.collection('userdetails').document(currentuser.uid).get().then((value) {
      if (value.data['currentGroup'] != null) {
      }
      ...

The main reason was that data for my uid (got from auth was not found in database).

A better approach would be to load/fill user object from the database using a constructor inmodels/user.dart and also fill my user data with random stuff. Like username: "empty" from the database

At least it will not show error in that case
This would be a better approach for error handling in the long term

@tmibvishal tmibvishal added the enhancement New feature or request label May 31, 2020
@tmibvishal tmibvishal changed the title Improvement in filling of user object from database from uid Improvement in filling of user object from database from uid @kshitijalwadhi May 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant