Flutter Prototype E-Commerce App
Flutter Prototype E-Commerce App
A cross-platform e-commerce application built with Flutter using the MVVM (Model-View-ViewModel) architecture pattern. This project demonstrates best practices for state management, navigation, data persistence, and interactive user experiences in Flutter.
You can find the project releases in the GitLab CI/CD Builds.
π± Project Overview
This application provides a complete e-commerce experience including:
- Interactive 3D onboarding experience
- User authentication with session management
- Product browsing and catalog management
- Shopping cart functionality with real-time updates
- Order management and history tracking
ποΈ Architecture
The project follows the MVVM (Model-View-ViewModel) architecture pattern:
- Models: Data structures representing core business logic
- Views: UI components that display data to the user
- ViewModels: Classes that handle business logic and state management
This separation ensures maintainable code organization, testability, and scalability.
π Project Structure
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
lib/
βββ main.dart # Entry point of the application
βββ models/ # Data models
β βββ cart_model.dart # Shopping cart item model
β βββ onboarding_model.dart# Onboarding screen model
β βββ order_model.dart # Order data model
β βββ product_model.dart # Product data model
β βββ user_model.dart # User data model
βββ services/ # Service classes
β βββ app_preferences.dart # Handles app preferences and local storage
βββ view_models/ # ViewModels (State management)
β βββ auth_view_model.dart # Authentication logic
β βββ cart_view_model.dart # Shopping cart management
β βββ navigation_view_model.dart # Navigation state management
β βββ onboarding_view_model.dart # Onboarding flow management
β βββ order_view_model.dart # Order management
β βββ product_view_model.dart # Product data management
βββ views/ # UI components
βββ cart_view.dart # Shopping cart screen
βββ home_view.dart # Home screen
βββ login_view.dart # Authentication screen
βββ main_layout.dart # Main application layout
βββ onboarding_view.dart # Onboarding screens
βββ orders_view.dart # Order history screen
βββ product_view.dart # Product details screen
βββ software_view.dart # Additional features screen
β¨ Key Features
π Authentication
- User login with credential validation
- Session persistence using SharedPreferences
- Automatic login for returning users
- Secure logout functionality
π Interactive 3D Onboarding
- Multi-step onboarding process with smooth transitions
- Interactive 3D model rendering using flutter_cube
- Custom animations for camera movement and object rotation
- Gradient background colors that transition between screens
- Skip functionality for returning users
- Progress tracking with animated indicators
Technical Implementation:
- Custom animation controllers for coordinated animations
- Vector3 interpolation for smooth camera movements
- Optimized rendering with RepaintBoundary
- Memory-efficient vector object reuse
- Asynchronous 3D model loading
π¦ Product Management
- Product listing with images and details
- Mock API integration with simulated network requests
- Loading state management
- Error handling for failed network requests
π Shopping Cart
- Add, remove, and update product quantities
- Real-time total calculation
- Item count tracking
- Empty state handling
- Persistent cart between sessions
π Order Management
- Order placement with cart validation
- Order history tracking
- Order status updates
- Mock API for demonstration purposes
π§ Navigation
- Tab-based navigation with state preservation
- Conditional navigation based on user authentication status
- Deep linking support
- Navigation state management through Provider
π¨ UI/UX Features
Theme and Styling
- Material Design 3 implementation
- Custom color schemes
- Consistent typography
- Responsive layouts for different screen sizes
Animations
- Custom page transitions
- Loading animations
- Interactive UI elements
- 3D model rotations and camera movements
Accessibility
- Semantic labels for screen readers
- Sufficient contrast ratios
- Touch target sizing
π§ State Management
This project uses Provider for state management, demonstrating:
- ChangeNotifier implementation
- Provider scoping
- Consumer pattern
- MultiProvider for multiple data sources
- Efficient rebuilds with selective listeners
π§© Dependencies
Core Dependencies
flutter
: Core Flutter frameworkprovider
: State management solutionshared_preferences
: Local data persistence
UI and Animation
flutter_cube
: 3D model renderinganimations
: Additional animation capabilities
Utils
intl
: Internationalization and formatting
π Getting Started
Prerequisites
- Flutter SDK (2.0.0 or higher)
- Dart SDK (2.12.0 or higher)
- Android Studio / VS Code with Flutter extensions
Installation
- Clone the repository:
1
git clone https://github.com/yourusername/flutter_ecommerce_app.git
- Navigate to the project directory:
1
cd flutter_ecommerce_app
- Install dependencies:
1
flutter pub get
- Run the app:
1
flutter run
π± Usage
Authentication
Use the following credentials to log in:
- Username:
admin
- Password:
password
Onboarding
The onboarding flow showcases:
- 5 sequential screens with unique information
- Interactive 3D model that responds to transitions
- Different camera angles for each screen
- Smooth color transitions between screens
- Navigation controls (next, previous, skip)
The onboarding flow will be shown on first app launch. You can reset it from the settings menu.
Development Notes
- The app uses mock data for products and orders
- Network requests are simulated with delays to demonstrate loading states
- Shared preferences are used to persist user session and app state
π§ͺ Testing
Unit Tests
Run unit tests with:
1
flutter test
Integration Tests
Run integration tests with:
1
flutter test integration_test
π Code Examples
Implementing a ViewModel
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
class ProductViewModel extends ChangeNotifier {
List<ProductModel> _products = [];
bool _isLoading = false;
String _errorMessage = '';
List<ProductModel> get products => _products;
bool get isLoading => _isLoading;
String get errorMessage => _errorMessage;
Future<void> fetchProducts() async {
_isLoading = true;
notifyListeners();
try {
// API call logic
_errorMessage = '';
} catch (e) {
_errorMessage = 'Failed to fetch products: ${e.toString()}';
}
_isLoading = false;
notifyListeners();
}
}
Using SharedPreferences
1
2
3
4
5
6
7
8
9
// Check if first launch
bool isFirstLaunch() {
return _preferences.getBool(_isFirstLaunchKey) ?? true;
}
// Set first launch complete
Future<void> setFirstLaunchComplete() async {
await _preferences.setBool(_isFirstLaunchKey, false);
}
π£οΈ Roadmap
Future enhancements planned for this application:
- Firebase integration for backend services
- User profile management
- Product search and filtering
- Payment gateway integration
- Push notifications
- Theme customization
- Localization support