Follow these steps to get your Flutter Boilerplate up and running:
flutter pub getThis project uses code generation for Freezed, JSON serialization, and Hive. Run:
flutter pub run build_runner build --delete-conflicting-outputsThis will generate:
*.freezed.dart- Freezed data classes*.g.dart- JSON serialization & Hive adapterstest_helper.mocks.dart- Test mocks
Use watch mode to auto-generate on file changes:
flutter pub run build_runner watch --delete-conflicting-outputsIf you see:
Bad state: GetIt: Object/factory with type X is not registered
Solution: Make sure lib/core/di/injection.dart includes all dependencies. Check that:
- All use cases are registered
- All repositories are registered
- All data sources are registered
- Services are registered before they're used
If you see errors about missing .freezed.dart or .g.dart files:
Solution: Run code generation:
flutter pub run build_runner build --delete-conflicting-outputsIf you see Hive box errors:
Solution: Hive is initialized in main.dart. Ensure:
await Hive.initFlutter();
await configureDependencies(); // This calls HiveService.init()Update lib/core/constants/api_constants.dart:
class ApiConstants {
static const String baseUrl = 'https://your-api-url.com/api/v1';
// ... rest of endpoints
}- Update
android/app/src/main/AndroidManifest.xml:
<manifest>
<!-- Add permissions -->
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<application>
<!-- Your app config -->
</application>
</manifest>- Minimum SDK version in
android/app/build.gradle:
android {
defaultConfig {
minSdkVersion 21 // Minimum for this project
}
}- Update
ios/Runner/Info.plist:
<dict>
<!-- Add network permissions -->
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<!-- Add notification permissions -->
<key>UIBackgroundModes</key>
<array>
<string>fetch</string>
<string>remote-notification</string>
</array>
</dict>- Minimum iOS version in
ios/Podfile:
platform :ios, '12.0'# Run on connected device/emulator
flutter run
# Run in release mode
flutter run --release
# Run on specific device
flutter run -d <device_id># Run all tests
flutter test
# Run with coverage
flutter test --coverage
# View coverage (requires lcov)
genhtml coverage/lcov.info -o coverage/html
open coverage/html/index.htmllib/
βββ core/ # Core functionality
β βββ di/injection.dart # β οΈ IMPORTANT: Dependency Injection
β βββ network/ # HTTP client
β βββ services/ # Core services
β βββ theme/ # Theming
βββ features/
β βββ auth/
β βββ data/ # Data layer
β βββ domain/ # Business logic
β βββ presentation/ # UI
βββ main.dart # App entry point
# Clean build
flutter clean && flutter pub get
# Check for issues
flutter doctor
# Analyze code
flutter analyze
# Format code
flutter format lib/
# Generate code
flutter pub run build_runner build --delete-conflicting-outputs
# Watch mode for code generation
flutter pub run build_runner watch
# Run tests
flutter test
# Build APK
flutter build apk --release
# Build iOS
flutter build ios --release- Run
flutter clean - Run
flutter pub get - Run code generation
- Restart IDE
- Try again
- Check for syntax errors in models
- Ensure all imports are correct
- Delete conflicting outputs:
flutter pub run build_runner build --delete-conflicting-outputs
- Check
injection.dart- all dependencies must be registered - Verify order - dependencies must be registered before use
- Use
getIt<Type>()to retrieve, notgetIt()
- Generate test mocks:
flutter pub run build_runner build - Check mock configurations in
test/helpers/test_helper.dart - Verify test fixtures in
test/fixtures/
β
Configure your API endpoints
β
Add your app branding (logo, colors, name)
β
Implement your features following the auth example
β
Write tests for new features
β
Customize themes in app_theme_data.dart
- Create feature in
lib/features/your_feature/ - Follow Clean Architecture (domain β data β presentation)
- Use Freezed for data classes and states
- Register dependencies in
injection.dart - Write tests in
test/features/your_feature/ - Run code generation
- Test and iterate
- Check
README.mdfor detailed documentation - Review
PROJECT_STRUCTURE.mdfor architecture details - Look at the
authfeature as a reference implementation - All code includes comments for guidance
Happy coding! π