Тёмный
No video :(

Firestore User with GetX | Todo App 

Tadas Petra
Подписаться 32 тыс.
Просмотров 15 тыс.
50% 1

Firestore User with GetX | Todo App
Join Me on Discord: / discord
In the last video we signed the user in with Firebase Auth, but now we are taking the next step and creating a user in Firestore.
Link to the Code: github.com/tad...
Great article with a different way to set up GetX: medium.com/@je...
Make sure to Like and Share!
And pls subscribe: shorturl.at/dsIO9
Thanks For Watching!
#flutter #getx #getxexample
This is the best mouse I've ever used!
MX Master 3: amzn.to/2VlkZQS
For my mac users, a cheap hub that I've been using with no complaints
Hiearcool USB-C Hub: amzn.to/3llsIsP
Also my favorite book ever, just so more people can read it :)
Brave New World by Aldous Huxley: amzn.to/3c7o91c

Опубликовано:

 

3 авг 2020

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 79   
@JKW3973
@JKW3973 2 года назад
Great tutorial for exactly what I was needing to know how to build thanks!
@ratrakone3761
@ratrakone3761 3 года назад
AuthResult is now UserCredential
@TPITEOTG
@TPITEOTG 7 месяцев назад
Thank you for excellent "best practices" guidance! Question: do you use VSC extension to fill "User.fromDocumentSnapshot"? Which extensions do you recommend? Thanks
@LeagueRandomPlayer
@LeagueRandomPlayer 3 года назад
as always epic work! some of the method and classes here are deprecated but worry not if you use at least android studio it will let you know. i recomend following the docs in FlutterFire along this great video!
@tadaspetra
@tadaspetra 3 года назад
Yes they unfortunately changed a lot on me haha. But hopefully people still are able to upgrade with the quality docs
@singhaseyha4375
@singhaseyha4375 2 года назад
that is the great tutorial, but can you share us how to get pagination with getX by using bindstream to append the next list?? please... i'm stuck
@TheCryptoFlowerman
@TheCryptoFlowerman 3 года назад
Love your videos!! Finally I am at a level to follow along(or maybe just not). Just one question.... when I try your example in flutter null safety I get an error (unexpected null value) and I can’t get me head around it....... instead of Getx in the rootScreen, I am using Obs... it works but for me the logic isn’t clear.... any suggestions? Keep on going with the videos, love them!
@jaimepremy
@jaimepremy 4 года назад
Another excellent video on GetX, and now with Firebase it's really getting exciting. Looking forward to see some videos on working with Firestore streams in GetX. Often times we need to combine and manipulate data from 2 or more documents, before we send this off to the view. I've been doing this with BLOC and RxDart up to now, but I guess it will be much less of a pain with GetX. I did some experimenting like this: final videos = List().obs; VideoController() { _videoService = VideoService(); } @override void onReady() async { videos.bindStream(loadVideos()); super.onInit(); } Stream loadVideos() { return _videoService.getAll(); } The controller is Lazy initialized with binding. The view looks like this: body: GetX(builder: (_) { if (_.videos.length == 0) { return Center(child: Text('Nothing to show yet...')); } return ListView.separated( separatorBuilder: (context, index) => Divider( color: Colors.grey, ), itemCount: _.videos.length, itemBuilder: (context, index) { return VideoTile(_.videos.elementAt(index)); }); }), The data shows up fine but does not update in real time if I modify some field in the db. The only way I found to have it update real time is to initialize the Controller in main.dart, but this creates the stream even before I requested it, so it's not very efficient. Imagine an app with dozens of streams getting initialized at startup. So I definitely need to master GetX a bit more and my hope's are on you for now ;-)
@tadaspetra
@tadaspetra 4 года назад
Jaime Baum that's definitely an important use case. One note, you're binding the stream onReady, maybe try onInit. I don't know if that would change anything but it's weird that it doesn't get updated 😕
@jaimepremy
@jaimepremy 4 года назад
@@tadaspetra Thanks, will try.
@jaimepremy
@jaimepremy 4 года назад
onInit didn't do the trick either. I ended up with this: //VideoController final videos = List().obs; @override void onInit() async { _videoService.getVideos(); } //VideoService void getVideos() async { Firestore.instance .collection("videos") .snapshots() .listen(_setVideos, cancelOnError: true); } void _setVideos(QuerySnapshot qss) { RxList videos = Get.find().videos; videos.clear(); List vdoList = qss.documents.map((e) => Video.fromSnapshot(e)).toList(); vdoList.forEach((element) { videos.add(element); }); } And now it works. I'm sure there's are better ways of doing this, but this might already help others with a similar requirement.
@CmdrVimes177
@CmdrVimes177 3 года назад
Hey Tadas, great series of tutorials - keep up the good work. I managed to follow thorough the Firebase Auth video ok and was able to update it to take into account the Firebase breaking changes but I have a problem with this video and I cannot see how to solve it. I am getting a Exception caught by widgets library - 'Null check operator used on null value' error in the Root() component. I think its the line that checks the user.uid that is the problem but I cannot see how to solve it. Can you help? Ok, so a further check seems to suggest that it is the entire Root() widget not the user.uid check as I first thought. Still stuck :-(
@GabrielHahn
@GabrielHahn 2 года назад
Same problem with me! Did you manage to solve this error?
@ibrahimmugaibel5811
@ibrahimmugaibel5811 2 года назад
@@GabrielHahn in DataBase>getUser method add "?" to (String? uid) and in the sign in method add '?' to (_authResult.user?.uid)
@elgusotube11
@elgusotube11 4 года назад
Cool Example. Do you make a example with GraphQL and GetX?. For example Hasura GraphQL works with suscriptions for real-time data changes, and having an example of these would be great. Thank you in advance for so many contributions.
@tadaspetra
@tadaspetra 4 года назад
Gustavo Delgado I've never used graphQL at all lol. I should check it out! Thanks!
@silverCap00
@silverCap00 3 года назад
It seems mouse and USB-c hub amazon site url are same. Anyway, always thank you for the great lectures!
@tadaspetra
@tadaspetra 3 года назад
You are right about that lol. Thank you for catching that and pointing it out
@jrheisler
@jrheisler 4 года назад
Cool stuff!
@tadaspetra
@tadaspetra 4 года назад
Thank you! Appreciate it!
@lbarria11
@lbarria11 3 года назад
Hi How are yo im getting this error in the root.dart in the uid is with a red mark builder: (_) { if (Get.find().user?.uid != null) { and give me this error The getter 'uid' isn't defined for the type 'String'. Try importing the library that defines 'uid', correcting the name to the name of an existing getter, or defining a getter or field named 'uid'.
@nikalags
@nikalags 3 года назад
same
@lbarria11
@lbarria11 3 года назад
what i do was delete the ?.uid!
@sakethparimi7664
@sakethparimi7664 3 года назад
In auth controller the user getter method returns a User not a String. and put _firebaseUser.value instead. Hope this helped!
@emreozbey9417
@emreozbey9417 2 года назад
@@sakethparimi7664 hey I fixed this error but now "Null check operator used on a null value" i am getting the error can you help me pls :)
@boonchaan
@boonchaan 3 года назад
Hi Todas I really enjoyed learning with you but I have a quick. maybe not that quici question. this is all very well for nativa apps in witch you log in and the app stays there. but for web the user can refresh. In my case im loosing the user at usercontroller. my idea is to create the database as Singleton passing the user uid to have it handy for saared data across users that is accessed by the user id at an array. but. the question is. can I somehow watch onAuthStatechange and set both the user at userController and the id at the singleton? maybe im a bit confusing. let me know if you have some time. cheers! and thanks for the amazing guidance
@crazymusicnetwork8844
@crazymusicnetwork8844 3 года назад
Great video how i can update UserController usercontroller = Get.put(UserController()); because i want reload new info of the user. Thanks
@tadaspetra
@tadaspetra 3 года назад
Create a function inside the UserController to update
@raymondmichael4987
@raymondmichael4987 3 года назад
I have been pulling my hair here for several minutes; Why I get squiggly line under AuthResult in the authController file; yelling "undefined class"; any thought btw, I tried to avoid "deprecated" errors, will that be the reason? :) That was the new thing I had to change too for comply with the new version of firebase; AuthResult => UserCredential case solved!!
@tadaspetra
@tadaspetra 3 года назад
Yea firebase and firestore changed a lot of things since this video came out unfortunately. but glad you figured it out!
@alvincastillo3931
@alvincastillo3931 4 года назад
Tadas impressive about getx but what about a splashscreen do you have to initialize the usercontroller at the same time that the authcontroller? or u will binding with the page ?
@tadaspetra
@tadaspetra 4 года назад
Alvin Castillo there's multiple ways to add a splash screen. I think either of your options would work. I'm not sure which way i prefer yet 😅
@blacksandedm3894
@blacksandedm3894 4 года назад
hey i have following error: AuthController not found. You need call put(AuthController()) anyone know when / where to call auth controller? If i call it in the wrapper i get a uid even if no user has been created
@tadaspetra
@tadaspetra 4 года назад
In the previous video we set up the Auth controller in the initialBinding 😊
@lamafattal3315
@lamafattal3315 2 года назад
Hello, whenever i hot restart the data is lost from the UI but its stored in firestore. How do i fix this problem?
@LtWittmann
@LtWittmann 3 года назад
I don't mean anything, but most of your tutorial is deprecated :( Could you update them? I may wrong tho, so sorry if I am
@tadaspetra
@tadaspetra 3 года назад
No you are right, it’s because Firebase updated all the setup required. They have a guide for how to update. The overall concept of the video still works, just need to update the initialization
@21izah
@21izah Год назад
By observable you mean notifying to changes right?
@syed.zain.gillani
@syed.zain.gillani 4 года назад
Hi, I am getting this error on this line email = doc['email']; [] isnt defined for the type DocumentSnapshot
@tadaspetra
@tadaspetra 3 года назад
Are you sure email field is defined for that document? In firestore
@jeremaine
@jeremaine 3 года назад
Calling [] directly is deprecated with the latest firestore
@sakethparimi7664
@sakethparimi7664 3 года назад
i am getting The getter 'message' isn't defined for the type 'Object' in catch(e)
@agreensh
@agreensh 4 года назад
Thanks for this, very useful. One thing I'm not sure of - why have you added email to your UserModel (and FireStore)? It's already part of the AuthResult from create or login (with email and password) - authResult.user.email - so no need to store it. Maybe it should still be part of the UserModel for convenience, but no need to store it separately - just initialize it from the AuthResult (save on FireStore data, and read/write counts).
@tadaspetra
@tadaspetra 4 года назад
Andy Greenshaw you are right it is stored in the Auth, but for my UserModel I usually like to store all the user information into that. So then I can call it once from wherever I need it and have it ready. For example: let’s say you have a profile page, and want to display all the info. Here you just make one function call and you have everything
@agreensh
@agreensh 4 года назад
@@tadaspetra That's why I say it should still be in the UserModel for convenience - but if you add/fetch it to/from FireStore as well, you're increasing your Firebase cost (assuming you have lots of users!).
@tadaspetra
@tadaspetra 4 года назад
Andy Greenshaw how would you retrieve the email for someone else’s profile page?
@agreensh
@agreensh 4 года назад
@@tadaspetra I wouldn't expose the email (privacy issue), only their name (and identified by the userid). If you do need the email (eg so one user can email another, if you really need to), then do that on the backend (via a cloud function).
@tadaspetra
@tadaspetra 4 года назад
Andy Greenshaw yea you can do that. But personally I just like to store, I feel like it makes things a lot easier. And Firebase charges per document read. So it is still one document read with the email in there
@user-rc2nt1tb2u
@user-rc2nt1tb2u 3 года назад
When I write this one👇🏻I get an error, any one can help me please? UserModel.fromDocumentSnapshot(DocumentSnapshot doc) { }
@victorlongoro4574
@victorlongoro4574 3 года назад
hi tadas, first thanks for the great tutorial it was awesome, simple to understand and it help me allots but the question here comes. am handling roles in my firebase i.e. admin and customer, am trying to manipulate the root so it provide the routes accordingly but it throw an error for me, try implemented this in provider and it works fine but in getx it really confusing, help me out
@kanegomolema7357
@kanegomolema7357 4 года назад
can you please do firebase storage tutorial
@tadaspetra
@tadaspetra 4 года назад
kanego molema already have one 😊 ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-xjA-yONXVzs.html
@humansmachines2732
@humansmachines2732 3 года назад
hey thanks for the great video but one question after closing the app and reopening it the user from the usercontroller is always null do i need to do some bindings or what else should I do ?
@tadaspetra
@tadaspetra 3 года назад
The user is stored on Firestore, so you could probably need to retrieve the information again, when you open it. I would do that in a binding, since it first checks auth and then leads you to another screen
@kribasrimal3778
@kribasrimal3778 3 года назад
Help! it says Null check operator used on a null value
@Krupupakku
@Krupupakku 3 года назад
same error here
@super10tamil93
@super10tamil93 3 года назад
String ? Name;
@TheCryptoFlowerman
@TheCryptoFlowerman 2 года назад
Same here!
@emreozbey9417
@emreozbey9417 2 года назад
same here
@novacoax
@novacoax Год назад
Same Here. 1 year after
@nikalags
@nikalags 3 года назад
In user.dart i can't use the variable id = doc.documentID; And in database.dart there is "Undefined class 'Firestore'." Help
@kishon2810
@kishon2810 3 года назад
id = doc.id
@Petter092
@Petter092 3 года назад
in database.dart replace Firestore for FirebaseFirestore
@rrbb
@rrbb 3 года назад
Hi , when i restart app, uid is stay but user.name is not load. i mean , when restarting app, root say, i have uid, go home, but home app bar have infinity loading, not name thanks for tutorial.
@lamafattal3315
@lamafattal3315 2 года назад
Hello, did u solve the problem?? Whenever i hot restart data is lost form the UI.
@mightycat2219
@mightycat2219 3 года назад
With respect, This channel is great but it really hard to learn from you. I would assume this is not a beginner lessons because you change the code between the video without explanation. I would suggest beginners to learn from Codex channel instead.
@tadaspetra
@tadaspetra 3 года назад
I appreciate the feedback. I try to cover the most important parts so that the videos don’t end up being too long. But I will take this into consideration
Далее
Firestore Stream with GetX | Todo App
13:24
Просмотров 17 тыс.
Firebase Auth with GetX | Todo App
14:05
Просмотров 33 тыс.
Мухочирон эхтиёт бошед!
01:31
Просмотров 108 тыс.
I forced EVERYONE to use Linux
22:59
Просмотров 334 тыс.
GetX in Flutter - Part 1 (Observables)
43:30
Просмотров 20 тыс.
Get CLI: A GetX Tool
10:44
Просмотров 18 тыс.
The Biggest Mistake Beginners Make When Web Scraping
10:21
Complete GetX State Management | Flutter
18:16
Просмотров 69 тыс.
Мухочирон эхтиёт бошед!
01:31
Просмотров 108 тыс.