Series 1 of 2 — Part 3 of 5
Building a Flutter Shopping App — Part 3: Cloud Firestore and Push Notifications
Series: Building a Flutter Shopping App — From Zero to Architecture
By this point the app had a working UI, Riverpod state management, and Firebase Auth. The next step was connecting it to a real backend — Firestore for user data persistence and Firebase Cloud Messaging for push notifications.
Integrating Cloud Firestore
I added cloud_firestore to pubspec.yaml and updated the plugin registrations. I used Firestore to persist user profile data and cart items server-side. The data structure was a top-level users collection, keyed by Firebase Auth uid, with a cart subcollection.
await FirebaseFirestore . instance . collection ( 'users' ) . doc ( currentUser . uid ) . collection ( 'cart' ) . doc ( product . id ) . set ( cartItem . toJson ());
Enter fullscreen mode
Exit fullscreen mode
One thing that caught me out was plugin registration.…