Skip to content

A Flutter template workspace for development and testing with organized navigation and clean architecture. Just for learning purpose

Notifications You must be signed in to change notification settings

tzrfabian/flutter_app_test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

33 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

flutter_app_test

A comprehensive Flutter template workspace with navigation, product management, and push notifications.

๐Ÿ“‹ Table of Contents

  1. About This Project
  2. ๐Ÿš€ Getting Started
  3. ๐Ÿ“ Project Structure
  4. โœจ Features Overview
  5. ๐Ÿ› ๏ธ Technical Implementation
  6. ๐ŸŽจ Customization Guide
  7. ๐Ÿ“ฑ Firebase Setup
  8. ๐Ÿ”ง Development Notes
  9. ๐Ÿ“š Resources

About This Project

This project serves as a beginner-friendly Flutter template that demonstrates modern app development practices. It includes:

  • Clean Architecture: Well-organized code structure
  • Navigation Systems: Multiple navigation patterns
  • Product Management: Complete e-commerce-style components
  • Push Notifications: Firebase Cloud Messaging integration
  • Material Design 3: Modern UI/UX patterns
  • Cross-platform Support: Works on all Flutter platforms

Perfect for: Learning Flutter, starting new projects, or understanding best practices.


Getting Started

Prerequisites

Before you start, make sure you have:

  • Flutter SDK (3.8.1 or higher) - Install Flutter
  • Dart SDK (included with Flutter)
  • IDE: VS Code, Android Studio, or IntelliJ
  • Firebase Account (for push notifications) - Firebase Console

Quick Setup

  1. Clone or download this template
  2. Install dependencies:
    flutter pub get
  3. Run the app:
    flutter run
  4. Start customizing for your project needs!

Development Commands

# Install dependencies
flutter pub get

# Run the app
flutter run

# Run tests
flutter test

# Clean build files
flutter clean

# Build for production
flutter build apk        # Android
flutter build ios        # iOS  
flutter build web        # Web
flutter build windows    # Windows

๐Ÿ“ Project Structure

lib/
โ”œโ”€โ”€ main.dart                      # ๐Ÿ  App entry point & Firebase initialization
โ”œโ”€โ”€ app.dart                       # โš™๏ธ App configuration and routing
โ”œโ”€โ”€ api/                           # ๐Ÿ”ฅ Firebase and API services
โ”‚   โ””โ”€โ”€ firebase_api.dart          # Firebase Cloud Messaging setup
โ”œโ”€โ”€ models/                        # ๐Ÿ“Š Data models
โ”‚   โ”œโ”€โ”€ models.dart                # Barrel export for models
โ”‚   โ””โ”€โ”€ product.dart               # Product data model
โ”œโ”€โ”€ sample/                        # ๐Ÿ—ƒ๏ธ Sample data
โ”‚   โ”œโ”€โ”€ img_carousel_data.dart     # Image carousel JSON data
โ”‚   โ””โ”€โ”€ product_sample_data.dart   # Product showcase JSON data
โ””โ”€โ”€ features/                      # ๐ŸŽฏ Feature-based organization
    โ”œโ”€โ”€ navigation/                # ๐Ÿงญ Navigation components
    โ”‚   โ””โ”€โ”€ main_navigation.dart   # Bottom navigation bar
    โ”œโ”€โ”€ routes/                    # ๐Ÿ—บ๏ธ App routing
    โ”‚   โ””โ”€โ”€ app_routes.dart        # Route definitions
    โ”œโ”€โ”€ pages/                     # ๐Ÿ“„ Application screens
    โ”‚   โ”œโ”€โ”€ home_page.dart         # Home with slider & products
    โ”‚   โ”œโ”€โ”€ products_page.dart     # Products with search & filter
    โ”‚   โ”œโ”€โ”€ user_info_page.dart    # User information form
    โ”‚   โ”œโ”€โ”€ profile_page.dart      # User profile
    โ”‚   โ”œโ”€โ”€ settings_page.dart     # App settings
    โ”‚   โ””โ”€โ”€ about_page.dart        # About information
    โ””โ”€โ”€ widgets/                   # ๐Ÿงฉ Reusable components
        โ”œโ”€โ”€ hamburger_menu.dart    # Navigation drawer
        โ”œโ”€โ”€ image_slider.dart      # Auto-sliding carousel
        โ”œโ”€โ”€ featured_product_list.dart # Horizontal product showcase
        โ”œโ”€โ”€ product_card_list.dart # Grid/list product cards
        โ”œโ”€โ”€ product_detail_dialog.dart # Product detail modal
        โ”œโ”€โ”€ user_info_form.dart    # User form widget
        โ””โ”€โ”€ user_info_dialog.dart  # User info display

android/
โ”œโ”€โ”€ app/
โ”‚   โ”œโ”€โ”€ google-services.json       # ๐Ÿ”ฅ Firebase configuration
โ”‚   โ””โ”€โ”€ src/main/AndroidManifest.xml # Android permissions

โœจ Features Overview

Navigation System

The app demonstrates multiple navigation patterns:

  • ๐Ÿ  Bottom Navigation: 5-tab navigation for main sections
  • ๐Ÿ” Hamburger Menu: Side drawer with gradient header
  • ๐Ÿ”— Programmatic Navigation: Named routes for flexible transitions
  • ๐Ÿ“ฑ Global Navigation: Works from anywhere using navigatorKey

Product Management

Complete e-commerce-style product system:

๐Ÿ›๏ธ Products Page

  • Grid View: 2-column responsive layout
  • ๐Ÿ” Real-time Search: Search by name or category
  • ๐Ÿท๏ธ Category Filtering: Dynamic filter chips
  • ๐Ÿ“Š Statistics: Product count and total price
  • โŒ Empty States: Helpful no-results messages

๐ŸŽด Product Cards

  • Flexible Display: Grid and list view support
  • ๐Ÿ–ผ๏ธ Image Loading: Network images with loading states
  • โญ Ratings: Star ratings and pricing
  • ๐Ÿ‘† Tap Actions: View details or custom actions

๐Ÿ” Product Details

  • ๐Ÿ“ท Large Images: Full-size product photos
  • ๐Ÿ“ Detailed Info: Category, rating, price display
  • ๐Ÿ›’ Add to Cart: Interactive cart functionality
  • ๐Ÿ“ฑ Responsive: Proper constraints for all screens

Push Notifications

Firebase Cloud Messaging integration:

๐Ÿ”” Notification Types

  • Foreground: In-app notifications while using the app
  • Background: System notifications when app is minimized
  • ๐Ÿ“ฒ Tap Navigation: Dynamic routing based on notification content

๐ŸŽฏ Dynamic Routing

  • Route by Keywords: Analyzes notification title/body
  • Smart Navigation: Routes to relevant pages automatically
  • ๐Ÿ”„ Fallback Logic: Defaults to home if no match found

Example routing keywords:

  • product โ†’ Products Page
  • profile โ†’ Profile Page
  • settings โ†’ Settings Page

โฐ Scheduled Notifications

  • Local Scheduling: Schedule notifications within the app
  • โšก Exact Alarms: Precise timing on Android 13+
  • ๐Ÿ”‹ Battery Optimization: Handles device restrictions

UI Components

๐ŸŽ  Image Slider

  • โฏ๏ธ Auto-sliding: Changes slides every 5 seconds
  • ๐Ÿ‘† Manual Control: Swipe gestures and arrow buttons
  • ๐Ÿ”ต Page Indicators: Animated dots show current slide
  • ๐Ÿ—ƒ๏ธ JSON Integration: Loads from structured data

๐Ÿ“ User Forms

  • โœ… Validation: Input validation with error messages
  • ๐Ÿ’ฌ Dialog Display: Shows entered information
  • ๐Ÿงน Form Clearing: Reset functionality

Technical Implementation

๐Ÿ—๏ธ Architecture Patterns

  • ๐Ÿ“ Feature-based Organization: Code grouped by functionality
  • ๐ŸŽฏ Single Responsibility: Each component has one clear purpose
  • ๐Ÿ”„ Separation of Concerns: UI, logic, and data are separated
  • ๐Ÿ“ฆ Barrel Exports: Clean imports with models.dart

๐Ÿ”ฅ Firebase Integration

Push Notifications Setup

// 1. Initialize Firebase
await Firebase.initializeApp();

// 2. Setup notifications
await FirebaseApi().initNotifications();

// 3. Handle incoming messages
FirebaseMessaging.onMessage.listen((message) {
  // Show notification while app is open
});

// 4. Handle notification taps
void handleNotif(RemoteMessage? message) {
  // Dynamic routing based on content
}

๐Ÿ“ฑ Android Configuration

  • ๐Ÿ“‹ Permissions: Notification and exact alarm permissions
  • ๐Ÿ”” Notification Channels: Proper Android notification setup
  • ๐Ÿ”‹ Battery Optimization: Handles device power management

๐ŸŽจ Material Design 3

  • ๐ŸŽจ Modern Theming: Latest Material Design components
  • ๐Ÿ“ฑ Responsive Layout: Adapts to different screen sizes
  • โ™ฟ Accessibility: Proper semantic labels and navigation
  • ๐ŸŒ™ Dark Mode Ready: Theme structure supports dark themes

Customization Guide

๐Ÿ†• Adding New Features

  1. Create Feature Folder:

    lib/features/your_feature/
    โ”œโ”€โ”€ pages/
    โ”œโ”€โ”€ widgets/
    โ””โ”€โ”€ data/
    
  2. Add Routes:

    // In app_routes.dart
    static const yourFeature = '/your-feature';
  3. Update Navigation:

    // Add to bottom navigation or drawer

๐ŸŽ›๏ธ Customizing Products

Add New Product Properties:

// In models/product.dart
class Product {
  final String description;  // Add new field
  final List<String> images; // Multiple images
  // ... existing fields
}

Modify Product Cards:

  • Edit product_card_list.dart for layout changes
  • Update product_detail_dialog.dart for detail view
  • Customize search logic in products_page.dart

๐Ÿ”” Notification Customization

Add New Route Keywords:

// In firebase_api.dart handleNotif method
if (title.contains('orders') || body.contains('orders')) {
  route = '/orders';
} else if (title.contains('cart') || body.contains('cart')) {
  route = '/cart';
}

Custom Notification Channels:

// Create different channels for different notification types
const urgentChannel = AndroidNotificationChannel(
  'urgent_channel',
  'Urgent Notifications',
  importance: Importance.high,
);

๐ŸŽ  Image Slider Customization

Change Auto-slide Timing:

// In image_slider.dart
Future.delayed(const Duration(seconds: 3), () {
  // Change from 5 to 3 seconds
});

Add Custom Transitions:

PageView.builder(
  physics: const BouncingScrollPhysics(), // Custom physics
  // ... other properties
);

Firebase Setup

๐Ÿ”ฅ Initial Setup

  1. Create Firebase Project:

  2. Android Setup:

    # Download google-services.json
    # Place in android/app/
  3. Add Dependencies:

    dependencies:
      firebase_core: ^2.24.2
      firebase_messaging: ^14.7.10
      flutter_local_notifications: ^16.3.2

๐Ÿ“ฒ Testing Push Notifications

  1. Get FCM Token:

    • Run app and check console for token
    • Copy the long token string
  2. Send Test Message:

    • Go to Firebase Console โ†’ Cloud Messaging
    • Click "Send your first message"
    • Enter title and body
    • Select "Single device" and paste token
  3. Test Routing:

    • Use keywords like "product", "profile", "settings" in title/body
    • App will navigate to appropriate page when tapped

๐Ÿ”ง Common Issues

Notifications not appearing?

  • Check app is running (not killed)
  • Verify device notification permissions
  • Test on different devices
  • Check battery optimization settings

Navigation not working?

  • Ensure routes are registered in app.dart
  • Check navigatorKey is set in MaterialApp
  • Verify route names match exactly

Development Notes

๐Ÿ“ฑ Platform Support

  • โœ… Android: Full feature support
  • โœ… iOS: Full feature support
  • โœ… Web: Basic functionality (no push notifications)
  • โœ… Windows/macOS/Linux: UI only

๐Ÿš€ Performance Tips

  • Uses IndexedStack to preserve page state
  • Lazy loading with ListView.builder for large lists
  • Network image caching for better performance
  • Proper async/await for smooth UI

๐Ÿงช Testing

  • Widget tests for form validation
  • Navigation testing examples
  • Firebase integration can be mocked for testing

๐Ÿ”ฎ Future Enhancements

  • State management (Provider, Riverpod, Bloc)
  • API integration for real data
  • User authentication
  • Local database (SQLite, Hive)
  • Advanced animations and transitions

Resources

๐Ÿ“– Learning Flutter

๐Ÿ”ฅ Firebase Resources

๐Ÿ“ฑ Material Design


๐Ÿ“„ License

This template is provided as-is for educational and development purposes. Feel free to modify and use according to your project needs.


Happy Coding! ๐Ÿš€

License

This template is provided as-is for development purposes. Modify and use according to your project needs.

About

A Flutter template workspace for development and testing with organized navigation and clean architecture. Just for learning purpose

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published