Skip to content

vasu-nageshri/Get_it

Repository files navigation

SmartShop Demo App

A complete Flutter e-commerce demo application showcasing GetIt as a dependency injection solution. This project demonstrates how to structure a real-world app using the Service Locator pattern with practical examples of authentication, cart management, checkout flow, and order tracking.

🎯 Project Purpose

This is a learning and demonstration project that shows:

  • How to use GetIt for dependency injection in a Flutter app
  • Real-world service architecture with proper separation of concerns
  • All 9 GetIt registration methods in practical scenarios
  • Proper async initialization and dependency management
  • Interactive demo screen to experiment with GetIt features

📱 Application Features

Complete E-commerce Flow

  1. Splash Screen - Async service initialization
  2. Login - User authentication with form validation
  3. Product Listing - Browse products with real-time cart updates
  4. Product Details - View individual product information
  5. Shopping Cart - Manage cart items
  6. Checkout - Process orders and generate receipts
  7. Order History - View past orders
  8. Scope Demo - Understand scoped services
  9. GetIt Showcase - Interactive demo of GetIt features

🏗️ Project Architecture

This app follows a feature-first architecture with clear separation between:

  • Models: Data structures (product_dm.dart, order_dm.dart)
  • Modules: Feature screens with their cubits (splash, login, home, cart, checkout, orders)
  • Repositories: Services for data access and business logic
    • local_repository/: Auth, secure storage
    • remote_repository/: API, cart, database, analytics, payment processing
  • Utilities: Navigation, helpers, toast notifications

Key Files

  • lib/main.dart - Application entry point
  • lib/service_locator.dart - All GetIt registrations (study this file!)
  • lib/modules/getit_showcase/ - Interactive demo screen
  • lib/utilities/navigation/app_routes.dart - Route definitions
lib/
├── main.dart                    # App entry point
├── service_locator.dart         # ⭐ GetIt setup - START HERE
├── models/                      # Data models
├── modules/                     # Feature screens + cubits
│   ├── splash/
│   ├── login/
│   ├── home/
│   ├── product_detail/
│   ├── cart/
│   ├── checkout/
│   ├── orders/
│   ├── scope_demo/
│   └── getit_showcase/          # ⭐ Interactive GetIt demo
├── repositories/                # Services & business logic
│   ├── local_repository/
│   └── remote_repository/
└── utilities/
    ├── navigation/
    └── toast_helper.dart

🚀 Quick Start

Prerequisites

  • Flutter SDK (3.0+)
  • Dart SDK (3.8.1+)

Installation & Run

# 1. Get dependencies
flutter pub get

# 2. Run the app
flutter run

# 3. Or run with specific device
flutter run -d chrome  # Web
flutter run -d macos   # macOS

Test Credentials

Login with any credentials:

  • Username: Any non-empty string
  • Password: Any string (4+ characters)

🎓 How to Use This Project

1️⃣ Start with service_locator.dart

Open lib/service_locator.dart to see how all services are registered. This is the heart of the dependency injection setup.

2️⃣ Explore the GetIt Showcase

Run the app → Home screen → "Open GetIt Showcase" button

  • Interactive demo of all GetIt features
  • Named instances, scopes, async init, swappable implementations
  • Real-time log output

3️⃣ Follow the App Flow

Navigate through the app to see GetIt in action:

  1. Splash → Async service initialization
  2. Login → Factory controllers
  3. Home → Singleton services, lazy loading
  4. Product Detail → FactoryParam with runtime data
  5. Cart → Global state management
  6. Checkout → Complex dependency chains
  7. Orders → Service dependencies

4️⃣ Study the Code

Each screen and service has inline comments explaining:

  • Which GetIt registration method is used
  • Why that method was chosen
  • How to retrieve the dependency

5️⃣ Experiment

Try modifying registrations in service_locator.dart:

  • Change a registerSingleton to registerLazySingleton
  • Add a new service with dependencies
  • Create a new factoryParam registration

📖 Learning Resources

This project includes comprehensive documentation:

Document Purpose
GETIT_DEEP_DIVE.md Complete guide: GetIt vs Provider/BlocProvider, all methods, limitations

🔍 What You'll Learn

By exploring this project, you'll understand:

Service Locator Pattern - Global dependency access without context
9 GetIt Registration Methods - When and why to use each
Dependency Management - Services depending on other services
Async Initialization - Proper startup sequencing
Scope Management - Temporary service lifecycles
Factory vs Singleton - Instance creation patterns
Named Instances - Multiple registrations of same type
Runtime Parameters - Dynamic service creation

🎯 Project Goals

This is a teaching project designed to:

  • Demonstrate GetIt in a realistic app structure
  • Show best practices for dependency injection
  • Provide hands-on examples of all GetIt features
  • Help developers choose between GetIt, Provider, and other DI solutions

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors