Development Setup
Development Setup
Section titled “Development Setup”This guide covers the development workflow, tools, and best practices for working with Lumo.
Development Workflow
Section titled “Development Workflow”Daily Development Process
Section titled “Daily Development Process”-
Start Development Server
Terminal window # Hot reload during developmentflutter run --hot# Debug mode with verbose loggingflutter run --debug --verbose -
Code Generation (when needed)
Terminal window # Generate code for Riverpod providers and other code generationdart run build_runner build# Watch for changes and regenerate automaticallydart run build_runner watch -
Testing
Terminal window # Run unit testsflutter test# Run widget testsflutter test test/widget_test.dart# Run integration testsflutter test integration_test/
Development Tools
Section titled “Development Tools”VS Code Extensions
Section titled “VS Code Extensions”Essential extensions for Lumo development:
{ "recommendations": [ "dart-code.flutter", "dart-code.dart-code", "ms-vscode.vscode-json", "bradlc.vscode-tailwindcss", "esbenp.prettier-vscode", "ms-vscode.vscode-typescript-next" ]}VS Code Settings
Section titled “VS Code Settings”{ "dart.flutterSdkPath": "", "dart.lineLength": 100, "dart.closingLabels": true, "dart.previewFlutterUiGuides": true, "dart.previewFlutterUiGuidesCustomTracking": true, "editor.formatOnSave": true, "editor.codeActionsOnSave": { "source.fixAll": true }, "files.associations": { "*.dart": "dart" }}Launch Configuration
Section titled “Launch Configuration”{ "version": "0.2.0", "configurations": [ { "name": "Debug App", "request": "launch", "type": "dart", "program": "lib/main.dart", "args": ["--flavor", "development"] }, { "name": "Profile App", "request": "launch", "type": "dart", "flutterMode": "profile", "program": "lib/main.dart" }, { "name": "Release App", "request": "launch", "type": "dart", "flutterMode": "release", "program": "lib/main.dart" } ]}Code Style & Standards
Section titled “Code Style & Standards”Dart Analysis Options
Section titled “Dart Analysis Options”include: package:flutter_lints/flutter.yaml
analyzer: exclude: - "**/*.g.dart" - "**/*.freezed.dart" strong-mode: implicit-casts: false implicit-dynamic: false
linter: rules: # Dart Style Guide - always_declare_return_types - always_put_control_body_on_new_line - avoid_empty_else - avoid_relative_lib_imports - avoid_unnecessary_containers - prefer_const_constructors - prefer_const_declarations - prefer_final_fields - prefer_final_locals - use_key_in_widget_constructors
# Security - avoid_print - avoid_web_libraries_in_flutter
# Performance - avoid_function_literals_in_foreach_calls - prefer_collection_literals - unnecessary_lambdasCode Formatting
Section titled “Code Formatting”# Format all Dart codedart format .
# Check formatting without applying changesdart format --set-exit-if-changed .
# Format specific filesdart format lib/features/otp/Import Organization
Section titled “Import Organization”Follow this import order:
// 1. Dart core librariesimport 'dart:async';import 'dart:convert';
// 2. Flutter librariesimport 'package:flutter/material.dart';import 'package:flutter/services.dart';
// 3. Third-party packagesimport 'package:riverpod/riverpod.dart';import 'package:realm/realm.dart';
// 4. App imports (absolute)import 'package:lumo/core/constants/app_constants.dart';import 'package:lumo/features/otp/domain/entities/otp_entry.dart';
// 5. Relative imports (if absolutely necessary)import '../widgets/custom_button.dart';Development Commands
Section titled “Development Commands”Common Flutter Commands
Section titled “Common Flutter Commands”# Project managementflutter create . # Initialize Flutter projectflutter pub get # Get dependenciesflutter pub upgrade # Upgrade dependenciesflutter pub deps # Show dependency tree
# Developmentflutter run # Run appflutter run --hot # Run with hot reloadflutter run --profile # Run in profile modeflutter run -d <device-id> # Run on specific device
# Buildingflutter build apk --debug # Debug APKflutter build appbundle --release # Release App Bundleflutter build ios --release # iOS release build
# Testingflutter test # Run testsflutter test --coverage # Run tests with coverageflutter drive # Run integration tests
# Analysisflutter analyze # Analyze codeflutter doctor # Check Flutter installationCustom Scripts
Section titled “Custom Scripts”Create helpful scripts in scripts/ directory:
#!/bin/bashecho "Starting Lumo development..."flutter pub getdart run build_runner buildflutter run --hot#!/bin/bashecho "Running Lumo tests..."flutter test --coverageflutter test integration_test/#!/bin/bashecho "Building debug version..."flutter cleanflutter pub getdart run build_runner buildflutter build apk --debugDebugging
Section titled “Debugging”Flutter Inspector
Section titled “Flutter Inspector”Use Flutter Inspector for UI debugging:
- Run app in debug mode
- Open Flutter Inspector in VS Code or browser
- Select widgets to inspect layout and properties
Logging
Section titled “Logging”// Use proper logging instead of print statementsimport 'package:flutter/foundation.dart';
// Debug logging (removed in release builds)if (kDebugMode) { debugPrint('Debug information: $data');}
// Development assertionsassert(() { // Validation code that only runs in debug mode if (someCondition) { throw FlutterError('Invalid state in development'); } return true;}());
// Conditional loggingvoid log(String message) { if (kDebugMode) { debugPrint('[${DateTime.now()}] $message'); }}Performance Profiling
Section titled “Performance Profiling”# Profile app performanceflutter run --profile
# Enable performance overlayflutter run --profile --trace-skiaHot Reload Best Practices
Section titled “Hot Reload Best Practices”Hot Reload Compatible Changes
Section titled “Hot Reload Compatible Changes”- Widget tree modifications
- Method implementations
- Variable assignments
- Adding/removing imports
Hot Restart Required
Section titled “Hot Restart Required”- Adding/removing classes
- Changing class hierarchy
- Modifying main() function
- Adding/removing static fields
- Changing generic type declarations
State Preservation
Section titled “State Preservation”// Preserve state during hot reloadclass _MyWidgetState extends State<MyWidget> { String _data = '';
@override void reassemble() { super.reassemble(); // Code here runs on every hot reload // Useful for development-only logic }}Environment Configuration
Section titled “Environment Configuration”Development Environment Variables
Section titled “Development Environment Variables”class DevConfig { static const bool enableLogging = true; static const bool enableAnalytics = false; static const String apiBaseUrl = 'https://api-dev.yourapp.com'; static const String firebaseProjectId = 'your-app-dev';
// Debug-specific features static const bool showPerformanceOverlay = false; static const bool showDebugBanner = true;}Conditional Compilation
Section titled “Conditional Compilation”// Different behavior for debug/releaseWidget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('Lumo'), actions: [ // Only show debug menu in debug mode if (kDebugMode) IconButton( onPressed: _showDebugMenu, icon: const Icon(Icons.bug_report), ), ], ), // ... rest of widget );}Database Development
Section titled “Database Development”Realm Studio Integration
Section titled “Realm Studio Integration”# Install Realm Studio for database inspection# Download from: https://realm.io/realm-studio/
# Connect to local database# File → Open Realm file# Navigate to app data directoryDatabase Debugging
Section titled “Database Debugging”// Helper for development database operationsclass DatabaseDebugHelper { static void printAllOtpEntries(Realm realm) { if (kDebugMode) { final entries = realm.all<OtpEntrySchema>(); for (final entry in entries) { debugPrint('OTP Entry: ${entry.issuer} - ${entry.account}'); } } }
static void clearAllData(Realm realm) { if (kDebugMode) { realm.write(() { realm.deleteAll<OtpEntrySchema>(); }); debugPrint('All OTP entries cleared'); } }}Git Workflow
Section titled “Git Workflow”Branch Strategy
Section titled “Branch Strategy”# Main branchesmain # Production-ready codedevelop # Integration branch for features
# Feature branchesfeature/qr-scanner-improvementsfeature/backup-encryptionbugfix/auth-flow-issue
# Release branchesrelease/1.1.0hotfix/1.0.1Commit Convention
Section titled “Commit Convention”# Conventional commit formatfeat: add QR code scanning for account importfix: resolve biometric authentication issuedocs: update setup guide with Firebase configurationstyle: format code according to Dart style guiderefactor: reorganize OTP generation logictest: add unit tests for OTP validationchore: update dependencies to latest versions
# Examplesfeat(otp): implement HOTP supportfix(auth): handle biometric unavailable statedocs(readme): add installation instructionsPre-commit Hooks
Section titled “Pre-commit Hooks”repos: - repo: local hooks: - id: flutter-analyze name: Flutter Analyze entry: flutter analyze language: system pass_filenames: false types: [dart]
- id: flutter-test name: Flutter Test entry: flutter test language: system pass_filenames: false types: [dart]
- id: dart-format name: Dart Format entry: dart format language: system types: [dart]Performance Monitoring
Section titled “Performance Monitoring”Development Performance Checks
Section titled “Development Performance Checks”// Monitor widget rebuild frequencyclass PerformanceLogger extends StatelessWidget { final Widget child; final String name;
const PerformanceLogger({ super.key, required this.child, required this.name, });
@override Widget build(BuildContext context) { if (kDebugMode) { debugPrint('Building $name at ${DateTime.now()}'); } return child; }}
// UsagePerformanceLogger( name: 'OtpListPage', child: OtpListPage(),)Memory Usage Monitoring
Section titled “Memory Usage Monitoring”// Development memory monitoringvoid logMemoryUsage() { if (kDebugMode) { // This is a simplified example debugPrint('Memory usage check at ${DateTime.now()}'); }}Next Steps
Section titled “Next Steps”Once your development environment is set up:
- Architecture Overview - Understand the codebase structure
- State Management - Learn Riverpod patterns
- Testing Guide - Write comprehensive tests
Happy coding! 🚀