Hi Tadas, what is the correct way to make a shopping cart with Firestore. I tried some approaches but many of them seemed quite inefficient to me. If we let user write the price then it will create a security problem. Anyone who might have bad intentions could easily manipulate the prices when writing to cart collection. And there is also a "paid custom options" problem. The only correct way is to create a cloud function? Would you mind making an episode for such situations? Thank you,
I have a very similar use case where I am trying to stream a shopping list. But when I use the provider I get an error saying: type 'List' is not a subtype of type 'List... somehow the type is lost or something. If I change the type to List it all works but I don't that thats the proper solution. Any ideas?
nick0c actually I think I know what it is. Are you reading the recipe from Firebase? If so Firebase returns a List you can map this to a List. Even if it’s not from Firebase wherever you retrieve the dynamic list just map it to a recipeitem list
@@tadaspetra This is what I have - I thought I was doing that... Stream getPersonalList() { print('Fetching personal list'); Stream _recipeItems = _db.collection('shopping_lists').document(userId).snapshots().map( (DocumentSnapshot documentSnapshot) => documentSnapshot.data['list'].map((item) { // print(item); return RecipeItem( category: item['category'], wholeLine: item['wholeLine'], recipeTitle: item['recipeTitle'], recipeId: item['recipeId'], purchased: item['purchased'], ); }).toList(), ); return _recipeItems; }
oh well, you are already mapping it to a List. So let me get this clear, you are using a StreamProvider, but you call this getPersonalList() function to start streaming it? If above is the case change the return type of the function to be StreamProvider and _recipeItems to the same type and it should work.
@@tadaspetra Yeah you're correct thats actually where I started. It actually works with the first snip that I had dynamic in there. Terrible formatting here but if I do: Stream getPersonalList() { print('Fetching personal list'); Stream _recipeItems = _db.collection('shopping_lists').document(userId).snapshots().map( (DocumentSnapshot documentSnapshot) => documentSnapshot.data['list'].map((item) { // print(item); return RecipeItem( category: item['category'], wholeLine: item['wholeLine'], recipeTitle: item['recipeTitle'], recipeId: item['recipeId'], purchased: item['purchased'], ); }).toList(), ); return _recipeItems; } and then in main.dart ---> class MyApp extends StatelessWidget { // This widget is the root of your application. @override Widget build(BuildContext context) { return MultiProvider( providers: [ StreamProvider( //Access withing the app -> var user = Provider.of(context); create: (_) => AuthService().user), StreamProvider( create: (_) => PersonalListDB().getPersonalList(), catchError: (context, error) { print( 'This is the error from stream provider in main screen *** $error'); }, ), ChangeNotifierProvider( create: (_) => RecipesDB(), ) ], child: MaterialApp( ... I still get the same error.
Hi, nice tutorial. Can you make a tutorial on how to retrieve a data, base on the user uid when they login to create a user profile? I have looking at so many tutorials but I always got an error.
Gilang Luthfi Aji Muzaki I actually have a video similar to what you’re looking for in the “Book Club App” playlist. It’s a playlist about creating a complete app. And it does something similar
@@tadaspetra yes I watch this tutorial no #8, But it does not show how you can put the user information into the UI. I've been trying using the the streambuilder method but i got null result.
Gilang Luthfi Aji Muzaki wherever you call to retrieve the userState do a setState after it. The data will be null at first, but it should load up once it is retrieved. Make sure you use a stateful widget too. If you look at the app in most recent github in screens/inGroup/secondCard uses the userState, could be helpful
when i accessing data with stream from firebase database where the data is in collection->document->collection ... im unable to retrive data ... can u help me with it
Thank you so much for this video. It helped me a lot.
Thank you for doing this!!
Wesley Barnes thank you for watching!
Very helpful. Thank you.
nick0c glad to help!!
Thank You So Much
Thank you
Thank you !
No, thank you!
Hi Tadas, what is the correct way to make a shopping cart with Firestore. I tried some approaches but many of them seemed quite inefficient to me. If we let user write the price then it will create a security problem. Anyone who might have bad intentions could easily manipulate the prices when writing to cart collection. And there is also a "paid custom options" problem. The only correct way is to create a cloud function? Would you mind making an episode for such situations? Thank you,
Epic Tutorial! What song are you playing at the intro?
Its called right here beside you
th-cam.com/video/9V3dCGjupXU/w-d-xo.html
Is it possible to stream an array inside of a collection? If it is I would love to see a video about it.
Kind regards Daniel
Thanks you
Thank you for watching 😊
i did the same but at the first time it shows nothing but when i go back and then come back to the page it shows items
I have a very similar use case where I am trying to stream a shopping list. But when I use the provider I get an error saying: type 'List' is not a subtype of type 'List... somehow the type is lost or something. If I change the type to List it all works but I don't that thats the proper solution. Any ideas?
nick0c actually I think I know what it is. Are you reading the recipe from Firebase?
If so Firebase returns a List you can map this to a List. Even if it’s not from Firebase wherever you retrieve the dynamic list just map it to a recipeitem list
@@tadaspetra This is what I have - I thought I was doing that... Stream getPersonalList() {
print('Fetching personal list');
Stream _recipeItems =
_db.collection('shopping_lists').document(userId).snapshots().map(
(DocumentSnapshot documentSnapshot) =>
documentSnapshot.data['list'].map((item) {
// print(item);
return RecipeItem(
category: item['category'],
wholeLine: item['wholeLine'],
recipeTitle: item['recipeTitle'],
recipeId: item['recipeId'],
purchased: item['purchased'],
);
}).toList(),
);
return _recipeItems;
}
oh well, you are already mapping it to a List.
So let me get this clear, you are using a StreamProvider, but you call this getPersonalList() function to start streaming it?
If above is the case change the return type of the function to be StreamProvider and _recipeItems to the same type and it should work.
@@tadaspetra Yeah you're correct thats actually where I started. It actually works with the first snip that I had dynamic in there. Terrible formatting here but if I do: Stream getPersonalList() {
print('Fetching personal list');
Stream _recipeItems =
_db.collection('shopping_lists').document(userId).snapshots().map(
(DocumentSnapshot documentSnapshot) =>
documentSnapshot.data['list'].map((item) {
// print(item);
return RecipeItem(
category: item['category'],
wholeLine: item['wholeLine'],
recipeTitle: item['recipeTitle'],
recipeId: item['recipeId'],
purchased: item['purchased'],
);
}).toList(),
);
return _recipeItems;
} and then in main.dart ---> class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MultiProvider(
providers: [
StreamProvider(
//Access withing the app -> var user = Provider.of(context);
create: (_) => AuthService().user),
StreamProvider(
create: (_) => PersonalListDB().getPersonalList(),
catchError: (context, error) {
print(
'This is the error from stream provider in main screen *** $error');
},
),
ChangeNotifierProvider(
create: (_) => RecipesDB(),
)
],
child: MaterialApp( ... I still get the same error.
Stream getPersonalList() {
print('Fetching personal list');
This first line in the function definition. Make that type Stream
Hi, nice tutorial. Can you make a tutorial on how to retrieve a data, base on the user uid when they login to create a user profile?
I have looking at so many tutorials but I always got an error.
Gilang Luthfi Aji Muzaki I actually have a video similar to what you’re looking for in the “Book Club App” playlist. It’s a playlist about creating a complete app. And it does something similar
@@tadaspetra yes I watch this tutorial no #8, But it does not show how you can put the user information into the UI. I've been trying using the the streambuilder method but i got null result.
Gilang Luthfi Aji Muzaki wherever you call to retrieve the userState do a setState after it. The data will be null at first, but it should load up once it is retrieved. Make sure you use a stateful widget too.
If you look at the app in most recent github in screens/inGroup/secondCard uses the userState, could be helpful
when i accessing data with stream from firebase database where the data is in collection->document->collection ... im unable to retrive data ... can u help me with it