Your AI powered learning assistant

🔥📱 Epic Ecommerce App with Admin Panel | Flutter x Firebase Tutorial for Beginners 2024

Introduction

00:00:00

Shivam introduces a tutorial on building a fully functional eCommerce app using Flutter and Firebase. The course will cover essential features such as setting up Firebase for backend support, user authentication, order tracking, and payment processing. Viewers are encouraged to like the video and subscribe for future content.

Complete App Demo of ECommerce App

00:00:44

User-Friendly E-Commerce App Features The e-commerce app features a user-friendly landing page that leads to an email authentication sign-up process using Firebase. After successful registration, users access the homepage showcasing categories like headphones and laptops, with advanced search capabilities. An admin panel allows product uploads directly visible to users, enhancing inventory management.

Seamless User Experience with Admin Oversight Users can view products in detail and make purchases through a Stripe payment gateway; order statuses are updated by admins via their control panel. The profile section enables image updates for personalization while maintaining seamless communication between user actions and admin oversight on orders. This comprehensive approach ensures beginners learn essential Flutter and Firebase skills effectively.

Creating a Landing Page UI from Scratch

00:09:18

Building an E-Commerce App with Unique Features An e-commerce app is being developed to create a complete electronic shop where users can purchase various items like headphones, watches, and laptops. This new project will feature an admin panel for product management and integrate Stripe payment gateway for transactions. The backend will utilize Firebase, offering a unique UI compared to previous apps created on the channel.

Creating Onboarding Page Layout in Flutter The development process begins by creating a landing or onboarding page in Flutter using stateful widgets. A customized background color is set up along with essential layout components such as containers and columns that organize content effectively. Debugging tips are provided to enhance the coding experience while ensuring images load correctly from designated folders within the project structure.

Designing User Interaction Elements Text elements are styled for visual appeal, including adjustments in font size and alignment within the column widget. A 'Next' button is designed using container widgets allowing navigation between pages seamlessly; styling includes padding adjustments and border radius settings for aesthetics. Overall design focuses on user-friendly interaction leading into sign-up processes smoothly integrated into the app's flow.

Creating a Home Page UI from Scratch

00:22:14

Utilizing Shape Boxes for Circular Elements To create a perfect circle for UI elements, use the shape box with circular properties instead of manually adjusting border radius values. The homepage is crucial in an e-commerce app as it serves as the first point of interaction after user sign-up; thus, it should be visually appealing to encourage product engagement.

Setting Up User Interface Basics The initial setup involves importing necessary components and establishing a basic layout that includes displaying the username prominently at the top left corner. By applying specific text styles such as color and font size adjustments, you can enhance visibility while maintaining aesthetic appeal on your homepage.

Streamlining Code with State Management Implementing state management simplifies code by allowing reuse of styling across multiple widgets without redundancy. Creating a support widget file helps store common text styles which can then be easily referenced throughout your application to maintain consistency and reduce complexity in coding efforts.

Incorporating Visuals into Layouts Adding visual elements like images requires careful attention to dimensions and alignment within rows or columns. Utilizing containers allows customization options such as height adjustments, margin settings, and rounded borders which contribute significantly towards achieving desired layouts effectively.

'Categories' Section Design Strategy 'Categories' sections are essential for guiding users through various product types available on an e-commerce platform. Implementing horizontal list views enables easy navigation between categories while ensuring each category icon is displayed clearly alongside relevant labels using appropriate spacing techniques.

Adding a Bottom Navigation Bar

01:05:43

Implementing a User-Friendly Bottom Navigation Bar A bottom navigation bar enhances user experience by providing easy access to key sections of an app. It includes three main tabs: the homepage, order page for viewing purchases, and profile management where users can update their information or log out. The implementation involves using a curved navigation bar package in the project.

Configuring Page References and State Management To set up the bottom navigation bar, create a list containing references to each page (homepage, orders, profile). Initialize state variables that track which tab is currently active and ensure proper sequencing so that tapping on icons navigates correctly between pages. Each icon's appearance is customized with colors and animations for smooth transitions.

Ensuring Seamless Navigation Experience The final setup allows seamless switching between different app sections through taps on respective icons in the bottom nav bar. By maintaining consistent background colors across screens, visual coherence improves usability while navigating from one section to another effortlessly without losing context within the application interface.

Creating a Detail Page UI from Scratch

01:16:28

Designing the Product Detail Page A product detail page is created to display specific information when a user taps on an item from the homepage. The UI includes essential elements like product images, details, pricing, and a payment gateway for order placement. A stateful widget named 'ProductDetail' is established with customized background colors and image assets.

Implementing Navigation Features To enhance user experience, a back arrow icon allows users to return to the homepage easily. This icon utilizes gesture detection for navigation functionality while maintaining proper padding and border radius for aesthetics.

Structuring Content Layouts Efficiently The layout incorporates containers that showcase product names, prices, descriptions along with styling adjustments using expanded widgets for responsiveness. Text alignment features ensure clarity in displaying important information about products alongside spacing management between text components.

Creating Interactive Purchase Options 'Buy Now' buttons are designed as interactive elements allowing direct payments through cards via Stripe integration planned later on. These buttons feature centered text within visually appealing containers ensuring ease of access during transactions.

Creating a LogIn Page UI from Scratch

01:33:32

Setting Up Your Login Page Structure To create a login page UI, start by setting up the project structure and importing necessary packages. Create a new file named 'login.dart' in the pages folder and define a stateful widget called Login. Use Scaffold to build your layout with an image from the assets folder displayed at the top of your screen.

Designing Input Fields with Text Widgets Incorporate text widgets for user instructions like "Sign In" and prompts for entering details below it. Add spacing between these texts using SizedBox to enhance readability, followed by input fields for email and password wrapped in containers that include custom styling such as colors, padding, border radius, hint text options.

Enhancing User Interaction Elements Include additional features like 'Forgot Password?' linked on one side of the form while ensuring proper alignment through Row widgets. Design a customized login button styled distinctly within its container; ensure it's responsive using MediaQuery so it adjusts well across different devices.

Finalizing Navigation Options Finally, provide navigation options for users without accounts by adding sign-up prompts beneath the login button along with appropriate styles applied to maintain visual consistency throughout. Ensure all elements are scrollable if they overflow beyond visible limits on smaller screens or devices.

Creating a SignUp Page UI from Scratch

01:50:04

Designing the Signup Page with Essential Fields The signup page UI is designed to include fields for name, email, and password. The 'forgot password' option is omitted since new users won't have a password yet. Text prompts are updated to guide users towards signing up or logging in if they already have an account. Navigation between the sign-up and login pages is implemented using gesture detectors that trigger navigation functions.

Integrating Firebase for Cross-Platform Functionality Connecting Firebase to both Android and iOS devices will be demonstrated after completing the signup UI setup. Specific guidance on resolving common errors encountered while running Flutter apps on real Android devices has been provided in previous series episodes, ensuring smooth integration of Firebase functionalities across platforms without rehashing detailed troubleshooting steps here.

Adding a Firebase to our App

01:56:36

To add Firebase to an app using the Android emulator, start by entering a project name, such as 'sop app'. After selecting the default account and creating the project, Firebase prepares it for use. Once ready, you can connect various platforms including iOS and Android to your Firebase setup. The process begins with connecting an iOS device before moving on to other connections.

Adding a iOS App with Firebase

01:57:26

To add an iOS app with Firebase in a Flutter project, start by obtaining the Apple bundle ID from Xcode. Open Xcode, navigate to 'Runner' and then 'Signing & Capabilities' to copy the bundle identifier. Register your app on Firebase and download the GoogleService-Info.plist file; if an older version exists, delete it before pasting this new one into your Xcode project under Info. After completing these steps and clicking through prompts, you will have successfully integrated your iOS app with Firebase.

Adding a Android App with Firebase

01:58:38

To integrate Firebase with an Android app, start by obtaining the Android package name from the build.gradle file. Register your app on Firebase and download the google-services.json file, ensuring it replaces any older versions in your project folder. Next, copy and paste specific plugin IDs into the build.gradle files while making necessary code adjustments to avoid errors related to class paths. Finally, add required dependencies before proceeding to finalize integration.

Adding a Packages from Pub.dev

02:01:08

To integrate Firebase into a Flutter app, start by adding essential packages from Pub.dev. Search for and install the Cloud Firestore package to enable data uploads, followed by Firebase Core for foundational support. Next, include the Firebase Auth package to facilitate email authentication. If you encounter version errors during installation, removing specific version numbers can resolve these issues automatically based on your Flutter setup. Finally, ensure proper connection with Firebase in your main file using necessary initialization commands.

Adding a Function for SignUp Page

02:03:46

Implementing the Signup Backend The signup page backend is designed to allow users to enter their name, email, and password. A text editing controller captures user input for each field. The form includes validation checks that prompt users if any fields are left empty before they can proceed.

Creating Validation Logic A global key tracks the state of the form fields ensuring all required information is provided during signup. Each text field uses a validator function that returns error messages when inputs are invalid or missing, enhancing user experience by guiding them through corrections.

Handling User Registration with Firebase Upon clicking sign up, a registration function processes valid entries using Firebase authentication methods. Error handling via try-catch blocks informs users about issues like weak passwords or duplicate emails while successfully registered accounts trigger confirmation messages displayed as snack bars.

Finalizing App Functionality and Testing After implementing necessary features in code and enabling email/password authentication on Firebase's console, testing confirms successful registrations redirecting new users to the homepage seamlessly. Adjustments ensure secure password entry while maintaining overall app functionality without errors.

Adding a Function for LogIn Page

02:22:20

Backend Setup for Login Page The login page requires a backend setup similar to the signup page, with adjustments for email and password inputs only. A global key, editing controllers, and functions are necessary for functionality. The user login function will handle authentication using Firebase's sign-in method.

Error Handling During User Authentication In the user login function, error handling is implemented through try-catch blocks to manage scenarios like non-existent users or incorrect passwords. Specific messages will be displayed via snack bars based on these errors to guide users in correcting their input.

Form Validation Mechanism A form widget wraps text fields that capture email and password inputs from users while validating them accordingly. Gesture detectors trigger validation checks before proceeding with the actual login process by calling the previously defined userLogin function.

Seamless Navigation After Authentication Upon successful registration or logging in of a new account, navigation occurs directly to the homepage without returning back unnecessarily after signing up or logging in again with existing credentials.

'Firestore' Integration For User Data Storage. 'Firestore' database integration allows storing registered user's details upon signup including name and email as part of an organized map structure within collections designated specifically for this purpose—facilitating easy access later on

.Shared preferences enable local storage of essential data such as ID ,name,email,and image which enhances app performance by reducing server calls when accessing frequently used information during sessions . This approach streamlines overall application efficiency significantly

Creating a Admin Login Page from Scratch

02:51:00

Designing Admin Login Page Interface The admin login page is designed to allow administrators to access the admin panel using a unique username and password. The UI resembles a signup page, with modifications made for functionality specific to admins. A new folder named 'admin' is created, where an 'admin_login.dart' file will house the code that imports necessary packages and sets up stateful widgets.

Implementing Functionality through Code Reuse To streamline development, existing signup code is copied into the admin login setup while making essential adjustments such as changing labels from sign-up to log in. Text editing controllers are implemented for handling input fields without validators since they aren't needed here. The main function triggers when clicking on the login button after entering credentials.

Authenticating Users via Firebase Integration A Firebase Firestore collection stores valid usernames and passwords which are checked against user inputs during authentication attempts. If mismatches occur—either in username or password—a snackbar alerts users of incorrect entries; otherwise, successful logins redirect them to an administrative home panel featuring various management functionalities like product addition and order oversight.

Creating an Add Product Page UI from Scratch

03:05:00

Setting Up Add Product Page Structure To create an Add Product Page UI, start by setting up a new file named 'add_product.dart' in the admin folder. Import necessary Material packages and define a stateful widget with a scaffold that includes an app bar titled "Add Product". Implement navigation for the back button to return to the home page.

Image Upload Functionality The main function of this page involves allowing admins to upload product images through tapping on a designated container featuring a camera icon. This action will open their phone gallery for image selection, which is then displayed within that container.

Input Fields for Product Details Next, provide input fields where admins can enter product details such as name and category using text fields and dropdown menus respectively. The dropdown should list predefined categories like watches, laptops, TVs, and headphones while ensuring proper styling throughout these elements.

Dropdown Menu Implementation Ensure functionality in selecting categories from the dropdown menu by implementing appropriate value handling methods so selected items are stored correctly without errors or underlines appearing unnecessarily beneath them.

'Final Touches: Submission Button' 'Finally', add an elevated button labeled 'Add Product' at the bottom of your form layout enabling submission actions once all required information has been filled out properly by administrators before finalizing additions into inventory systems effectively!

Adding a Function to Add Product Page

03:25:59

Integrating Backend Functionality with Firebase To enhance the product page, a backend is needed for image uploading. The implementation involves integrating Firebase Storage and an Image Picker package to allow users to select images from their gallery or camera. After installing these packages in the project, functions are created for picking images and handling file uploads.

Retrieving Images Using Asynchronous Functions A function named 'getImage' retrieves selected images as files using asynchronous methods. Once an image is picked, it’s stored in a variable that will later be uploaded to Firebase Storage if certain conditions regarding product name input are met by the admin user.

Efficiently Uploading Product Data Across Categories The upload process checks whether an image has been selected before proceeding with storing data into Firestore database collections based on categories like laptops or watches. A single function handles multiple categories efficiently without redundant code creation while ensuring all necessary details such as names and download URLs of products get recorded properly.

Streamlining Admin Workflow During Product Additions 'AddProduct' functionality allows admins to add new items seamlessly after each entry without needing additional navigation steps back through forms; this improves workflow efficiency significantly during inventory management tasks within applications designed for e-commerce purposes

.plist Configuration Ensuring Compatibility on iOS Devices. 'Info.plist' adjustments ensure compatibility when utilizing iOS devices alongside Flutter apps—this step prevents crashes related specifically towards accessing device galleries via implemented plugins like Image Picker which require specific permissions granted beforehand

'ProductDetailPage’ showcases essential information including price points along with detailed descriptions added directly by administrators upon item addition processes completed earlier thus providing comprehensive insights about available merchandise at any given time enhancing overall shopping experience offered through application interfaces developed herewith

Showing Products on Category Page by GridView

03:52:17

Implementing Category Navigation with GridView To display products by category, a GridView is implemented that redirects users to specific pages for each product type like headphones or laptops. A GestureDetector captures taps on categories and navigates the user to a new page named 'Category Products'. This involves setting up an app bar with navigation options and preparing the layout for displaying products in grid format.

Dynamic Data Fetching Using StreamBuilder A StreamBuilder fetches data from Firebase collections dynamically, allowing real-time updates when documents change. The setup includes checking if data exists before rendering it in a grid view; otherwise, it displays an empty container. Each item displayed consists of images, names, and prices sourced directly from Firebase document fields.

Efficient Document Retrieval Functionality The function retrieves all relevant documents based on selected categories without needing multiple functions for different types. It utilizes asynchronous programming principles to ensure smooth loading of product information upon navigating into category-specific views within the application structure.

UI Optimization for Enhanced User Experience After implementing UI adjustments such as margins and padding around elements within lists of items shown per category (like watches), visual overflow issues are resolved ensuring proper spacing between components while maintaining aesthetic appeal across various device sizes during testing phases post-deployment.

Adding a Function to Product Detail Page

04:10:25

Seamless Product Detail Navigation A function is added to the product detail page, allowing users to tap a plus icon and be redirected for ordering. The necessary details such as image, name, and price are passed correctly using specific field names from the document. After ensuring all fields are accurately referenced without errors, tapping on an item displays its details effectively.

User Data Retrieval & Payment Integration Plans To enhance functionality further, integration of Stripe payment gateway will allow card payments directly linked with order placement visible in the admin panel. Additionally, user data like username and profile image is retrieved through shared preferences upon app initialization; if loading takes time due to null values during retrievals, a circular progress indicator informs users until their information appears after signing up successfully.

Adding a Stripe Payment Gateway in E-Commerce App

04:19:09

Integrating Stripe Payment Gateway Requires Attention Stripe is a widely used payment gateway, essential for e-commerce applications. To integrate it into your Flutter app, ensure you follow all steps meticulously to avoid common errors that arise from skipping processes. This integration requires specific configurations in the Android manifest and Kotlin files.

Setting Up Your Stripe Account Creating an account on Stripe is straightforward; simply visit stripe.com and sign up or log in if you already have an account. Once logged in, access the dashboard where you'll find options for test mode transactions using publishable keys and secret keys necessary for development purposes.

Installing Flutter Package Successfully To use the Flutter package for Stripe payments effectively, install it via Pub.dev by adding its dependency to your pubspec.yaml file. Ensure compatibility with existing versions of dependencies; removing version constraints can resolve loading issues during installation.

Essential Configuration Steps For Android Integration Configuring Android settings involves several critical changes within various files such as build.gradle and AndroidManifest.xml to support functionality like theme adjustments and activity types required by the Stripe SDK. Each step must be followed precisely without omissions to prevent runtime failures when deploying on real devices.

'iOS' Platform Requirements Must Be Met 'iOS' platform requirements include setting a minimum deployment target which should be at least 13.x through Podfile modifications ensuring compatibility across iPhone devices or emulators while integrating similar functionalities as done previously with 'Android'.

Adding a Complete Function to Order Page

04:58:00

Creating the Current Orders Page The process begins with setting up a 'Current Orders' page in the app, featuring an AppBar and a list view to display all user orders. A scaffold is created for layout purposes, incorporating styling elements like background color and text styles.

Implementing StreamBuilder for Order Display Utilizing StreamBuilder allows dynamic fetching of order data from Firestore without repetitive code. The UI includes product images alongside names and prices formatted within rows and columns to enhance visual appeal.

Fetching User-Specific Orders from Database A function retrieves only those orders associated with the logged-in user's email by querying Firestore's collection based on matching criteria. This ensures that users see their specific order history rather than all entries in the database.

Testing Order Placement Functionality 'Buy Now' functionality is tested using sample payment details, confirming successful transactions reflected on both user interface and backend database. Users can navigate back to check their recent purchases seamlessly after placing an order.

Adding Delivery Status Updates for Transparency 'On-the-way' status updates are integrated into each order entry displayed on the current orders page, enhancing customer experience by providing real-time tracking information about delivery progress through simple text displays.

Handling Orders from Admin Panel

05:18:40

Creating an Admin Order Management Interface An admin panel is set up to manage orders, starting with creating a new file for all orders. The interface includes a centered title and utilizes margins for better visibility on mobile devices. An app bar is added to facilitate navigation back to the home page.

Displaying Pending Orders in Real-Time The system retrieves pending orders marked as 'on the way' from the database using streams. A function fetches these order details while ensuring that delivered items are not displayed anymore, maintaining focus on active deliveries.

Enhancing User Information Display User information such as name and email is presented alongside product details like name and price within each order entry. Adjustments ensure proper layout without overflow errors by utilizing containers effectively.

Implementing Status Update Functionality 'Done' buttons allow admins to mark orders as delivered directly through user interactions, updating their status in real-time via Firebase integration. This functionality ensures seamless tracking of delivery statuses across both admin and user interfaces.

Adding a Complete Function to Search a Product

05:33:53

Implementing Dynamic Product Search A dynamic search feature will be added to the e-commerce app, allowing users to see product suggestions as they type. For instance, typing 'h' displays all products starting with that letter. This functionality mirrors popular platforms like Amazon and Flipkart.

Creating Functions for Search Logic To facilitate searching, a function named 'initiateSearch' is created which triggers when text is entered in the search field. It checks if any input exists; if not, it resets states accordingly. The system prepares an empty list to store query results based on user input.

Setting Up Firebase Integration Products are uploaded into a new collection within Firebase called 'products', containing various items across categories. Each product entry includes its first character stored separately for efficient querying during searches.

'Add Products' Functionality Development 'addProducts' method allows adding mixed-category products into the database while ensuring each entry's initial character aligns with its name for accurate retrieval later on during searches.

Building Query Mechanism Based on User Input . A loop iterates through characters typed by users and queries matching documents from Firestore where names start with those letters using substring logic combined with uppercase conversion for consistency in comparisons.

Displaying Results Dynamically Within UI Components . As users type their queries, relevant results populate dynamically via ListView widgets displaying images and names of matched products without showing other categories or unrelated content until cleared by closing actions initiated by tapping an icon button.”

Adding a Profile Page to Ecommerce App

06:08:55

Creating User Profile Page Layout The profile page of the eCommerce app is being developed, starting with a scaffold that includes a background color and an app bar labeled 'Profile'. The design will incorporate user details such as their image, name, email address, along with options to sign out or delete the account. A crucial requirement for App Store submission is including a delete account feature.

Fetching User Data Efficiently User data like images and personal information are retrieved using shared preferences. If no data exists upon loading the profile page, a circular progress indicator displays until it’s available. Once loaded successfully from shared preferences, user images can be displayed in specified dimensions within the layout.

Implementing Image Upload Feature To enhance functionality on the profile page further allows users to change their display picture via an image picker integrated with Firebase storage for uploading new photos. After selecting an image from their device's gallery through gesture detection triggers this process seamlessly while ensuring uploaded links are saved back into shared preferences.

. Correct Widget Wrapping Practices. 'ClipRRect' widget usage ensures rounded corners on user images but must not wrap around center widgets directly; instead wrapping them correctly prevents rendering issues during testing phases when changing pictures multiple times becomes necessary without errors appearing unexpectedly due to minor mistakes made earlier in development stages

'Material Widgets' provide visual enhancements by adding elevation effects alongside border radius adjustments creating visually appealing containers displaying usernames and emails effectively styled according to application standards set previously throughout other pages designed similarly across different sections enhancing overall consistency within UI/UX experience offered here too!