Build an inventory management system by creating a products collection with stock levels and a stock_movements collection that logs every receive, sell, adjustment, and return event. Use FieldValue.increment for atomic stock updates so concurrent transactions never cause count drift. Add barcode scanning for fast product lookup, low-stock alerts when inventory drops below reorder levels, and a dashboard showing total inventory value and slow-moving items.
Building an Inventory Management System in FlutterFlow
Tracking inventory accurately is essential for any product-based business. This tutorial builds a complete inventory system with product cataloging, stock movement logging, barcode scanning for fast receiving, low-stock alerts, and a management dashboard. Every stock change is logged as a movement for full audit trail visibility.
Prerequisites
- A FlutterFlow project with Firestore and authentication configured
- Basic familiarity with Firestore queries and Custom Actions
- A mobile device for testing barcode scanning functionality
- Sample product data with SKU codes
Step-by-step guide
Create the Firestore data model for products and stock movements
Create the Firestore data model for products and stock movements
Create a products collection with fields: sku (String, unique), name (String), category (String), currentStock (Integer), reorderLevel (Integer), costPrice (Double), sellPrice (Double), supplierId (String), imageUrl (String), location (String for warehouse or shelf position), lastUpdatedAt (Timestamp). Create a stock_movements collection with fields: productId (String), type (String: received, sold, adjustment, return), quantity (Integer, positive for additions, negative for removals), reference (String for order number, PO number, or audit ID), userId (String, who performed the action), notes (String), timestamp (Timestamp). Add indexes on products for category plus currentStock filtering and on stock_movements for productId plus timestamp ordering.
Expected result: Firestore has products and stock_movements collections with indexes for efficient querying.
Build the product inventory list with stock-level indicators
Build the product inventory list with stock-level indicators
Create an InventoryPage with a TextField for search at the top. Add ChoiceChips for category filtering. Below, add a ListView with a Backend Query on products, filterable by category and searchable by name or SKU. Each product row displays the name, SKU, currentStock as a number, and a stock-level color indicator: a Container with background color green when currentStock is above reorderLevel times 2, yellow when between reorderLevel and reorderLevel times 2, and red when at or below reorderLevel. Show the location text and costPrice. Tap a product to navigate to ProductDetailPage showing full details, stock movement history, and action buttons.
Expected result: A product list with search, category filtering, and color-coded stock level indicators at a glance.
Implement barcode scanning for product lookup and stock receiving
Implement barcode scanning for product lookup and stock receiving
Add a barcode scan IconButton on the InventoryPage header. Create a Custom Widget using the mobile_scanner package that opens the camera and detects barcodes. When a barcode is scanned, query the products collection where sku equals the scanned value. If found, navigate to the ProductDetailPage. If not found, show an option to create a new product with the SKU pre-filled. For receiving stock, on the ProductDetailPage add a Receive Stock button that opens a BottomSheet with quantity TextField (numeric), reference TextField (PO number), and a Scan button that scans the product barcode for verification. On submit, call a Custom Action that uses FieldValue.increment to atomically add the quantity to currentStock and creates a stock_movement document with type 'received'.
1// Custom Action: receiveStock2import 'package:cloud_firestore/cloud_firestore.dart';34Future<void> receiveStock(5 DocumentReference productRef,6 int quantity,7 String reference,8 String userId,9) async {10 // Atomic increment - safe for concurrent updates11 await productRef.update({12 'currentStock': FieldValue.increment(quantity),13 'lastUpdatedAt': FieldValue.serverTimestamp(),14 });15 // Log the movement16 await FirebaseFirestore.instance.collection('stock_movements').add({17 'productId': productRef.id,18 'type': 'received',19 'quantity': quantity,20 'reference': reference,21 'userId': userId,22 'timestamp': FieldValue.serverTimestamp(),23 });24}Expected result: Scanning a barcode looks up the product instantly. Receiving stock atomically updates the count and logs a movement.
Build the stock movement log and adjustment flow
Build the stock movement log and adjustment flow
On the ProductDetailPage, add a ListView below the product details querying stock_movements where productId equals the current product, ordered by timestamp descending. Each movement row shows the type as a colored badge (green for received, red for sold, blue for adjustment, orange for return), the quantity with plus or minus prefix, the reference, the user who performed it, and the timestamp. Add a Stock Adjustment button for inventory corrections. The adjustment BottomSheet has a DropDown for adjustment reason (damage, theft, count correction, expiry), a quantity TextField (positive or negative), and a notes TextField. Submit creates a stock_movement with type 'adjustment' and updates currentStock with FieldValue.increment of the quantity value.
Expected result: A complete audit trail of all stock movements for each product with the ability to make corrections via adjustments.
Create the dashboard with alerts and inventory value
Create the dashboard with alerts and inventory value
Create a DashboardPage with summary cards at the top: Total Products count, Total Inventory Value (sum of currentStock times costPrice across all products, calculated by a Custom Function), and Low Stock Count (products where currentStock is at or below reorderLevel). Below the summary, add a Low Stock Alerts section: a ListView querying products where currentStock is less than or equal to reorderLevel, ordered by currentStock ascending. Each alert card shows the product name, current stock in red, reorder level, and a Reorder button. Add a second section for Recent Activity: a ListView of the most recent stock_movements across all products. Optionally add a Custom Widget with fl_chart showing a BarChart of stock value by category.
Expected result: A management dashboard with inventory value totals, low-stock alerts for immediate action, and recent activity monitoring.
Add stock audit and reporting functionality
Add stock audit and reporting functionality
Create a Stock Audit flow: a page listing all products in a scrollable form where each row shows the product name, system stock count, and a TextField for the physical count entered during a warehouse walk. On submit, compare physical counts against system counts. For mismatches, automatically create stock_movement documents with type 'adjustment' and the difference as quantity. Display a summary report showing total matches, total mismatches, and net variance. Add a Cloud Function for generating reports: query stock_movements for a date range grouped by product, calculate turnover rate (sold quantity divided by average stock), and identify slow-moving items (zero sales in 30 days). Export as CSV to Firebase Storage.
Expected result: A stock audit process that reconciles physical counts with system records and generates movement reports.
Complete working example
1FIRESTORE DATA MODEL:2 products/{productId}3 sku: String (unique)4 name: String5 category: String6 currentStock: Integer7 reorderLevel: Integer8 costPrice: Double9 sellPrice: Double10 supplierId: String11 imageUrl: String12 location: String13 lastUpdatedAt: Timestamp1415 stock_movements/{movementId}16 productId: String17 type: "received" | "sold" | "adjustment" | "return"18 quantity: Integer (+/-)19 reference: String20 userId: String21 notes: String22 timestamp: Timestamp2324PAGE: InventoryPage25WIDGET TREE:26 Column27 ├── Row28 │ ├── TextField (search by name/SKU)29 │ └── IconButton (barcode scan → mobile_scanner)30 ├── ChoiceChips (category filter)31 └── ListView (products, filtered + sorted)32 └── Container (product row)33 ├── Image (product image)34 ├── Column (name + SKU + location)35 ├── Container (stock level: color-coded)36 │ └── Text (currentStock)37 └── Text (costPrice)3839PAGE: ProductDetailPage40WIDGET TREE:41 Column42 ├── Container (product info card)43 ├── Row (action buttons)44 │ ├── Button (Receive Stock → BottomSheet)45 │ ├── Button (Adjust Stock → BottomSheet)46 │ └── Button (Record Sale)47 └── ListView (stock movements, ordered by timestamp desc)48 └── Container (movement row)49 ├── Badge (type, color-coded)50 ├── Text (quantity +/-)51 ├── Text (reference)52 └── Text (timestamp)5354PAGE: DashboardPage55WIDGET TREE:56 Column57 ├── Row (summary cards)58 │ ├── Container (Total Products)59 │ ├── Container (Inventory Value)60 │ └── Container (Low Stock Count, red)61 ├── Text ("Low Stock Alerts")62 ├── ListView (products where currentStock <= reorderLevel)63 │ └── Container (alert card: name + stock + Reorder button)64 ├── Text ("Recent Activity")65 └── ListView (recent stock_movements, limit 20)Common mistakes when creating an Inventory Management System in FlutterFlow
Why it's a problem: Using read-then-write for stock updates instead of atomic FieldValue.increment
How to avoid: Always use FieldValue.increment(-quantity) for sales and FieldValue.increment(quantity) for receiving. This performs atomic operations that handle concurrent updates correctly.
Why it's a problem: Updating stock levels without creating a movement record
How to avoid: Every stock change must create a stock_movement document. Use a Custom Action that performs both the stock update and movement creation together.
Why it's a problem: Setting reorder levels to zero or not setting them at all
How to avoid: Set reorder levels based on lead time and average daily sales. For example, if it takes 5 days to receive new stock and you sell 10 per day, set the reorder level to at least 50.
Best practices
- Use FieldValue.increment for all stock updates to handle concurrent operations atomically
- Log every stock change as a movement document for a complete audit trail
- Color-code stock levels (green, yellow, red) for instant visual assessment
- Implement barcode scanning for fast product lookup during receiving and audits
- Set meaningful reorder levels based on lead times and sales velocity
- Run periodic stock audits comparing physical counts to system counts
- Calculate inventory value and turnover rates for informed purchasing decisions
Still stuck?
Copy one of these prompts to get a personalized, step-by-step explanation.
I want to build an inventory management system in FlutterFlow with Firestore. Show me the data model for products and stock movements, atomic stock updates with FieldValue.increment, barcode scanning for receiving, low-stock alerts, and a management dashboard.
Create an inventory dashboard with three summary cards at the top (total products, inventory value, low stock alerts), a list of low-stock items in the middle with colored indicators, and recent stock activity at the bottom.
Frequently asked questions
Can I track inventory across multiple warehouse locations?
Yes. Add a location field to stock_movements and add a per-location stock map on the product document. The dashboard can then show stock breakdown by location and allow transfers between locations as a movement type.
How do I handle products with variants like size and color?
Create a product_variants subcollection under products with fields for variant name, SKU, and currentStock. Each variant has its own stock level and movement history. The parent product aggregates total stock across all variants.
Can I generate purchase orders automatically when stock is low?
Yes. Create a Cloud Function triggered by product updates. When currentStock drops to or below reorderLevel, generate a purchase_order document with the product, supplier, and suggested quantity. Notify the purchasing team.
How do I prevent selling more than available stock?
In the sale Cloud Function, use a Firestore transaction: read currentStock, verify it is greater than or equal to the sale quantity, then decrement. If insufficient, throw an error and show an out-of-stock message to the user.
Can I import products from a spreadsheet?
Yes. Create a Cloud Function that accepts a CSV file upload, parses each row, and creates product documents in Firestore. Include validation for required fields and duplicate SKU detection.
Can RapidDev help build an enterprise inventory system?
Yes. RapidDev can implement full inventory platforms with multi-warehouse management, purchase order automation, supplier portals, batch and serial number tracking, demand forecasting, and ERP integrations.
Talk to an Expert
Our team has built 600+ apps. Get personalized help with your project.
Book a free consultation