A comprehensive Flutter TDD (Test-Driven Development) brick for generating complete Flutter projects with Clean Architecture, Bloc/Cubit state management, and production-ready features.
- Domain Layer: Entities, use cases, and repository interfaces
- Data Layer: Data sources, models, and repository implementations
- Presentation Layer: Pages, cubits, and navigation
- Dependency Injection: GetIt-based service locator pattern
- Complete login/logout flow
- Token-based authentication with refresh token support
- Secure local storage for user data
- Automatic token refresh with Dio interceptors
- Splash screen with user session validation
- Custom AppButton: Enhanced button widget with loading states, icons, and accessibility
- AppTextFormField: Styled form fields with validation
- AppBar: Customizable app bar component
- CachedNetworkImage: Optimized image loading with caching
- PaginatedListView: Efficient list rendering with pagination
- Theme System: Centralized color scheme and text styles
- Dio Integration: HTTP client with interceptors
- API Response Handling: Standardized response models
- Error Management: Comprehensive error handling and failure types
- Logging: Request/response logging with TalkerDioLogger
- Socket Support: WebSocket implementation ready
- Flutter Bloc: Cubit-based state management
- Pagination Cubit: Built-in pagination handling
- Navigation Management: Custom navigator with transition support
- Image Picker Service: Camera and gallery integration
- Location Service: GPS and location handling
- Payment Service: Payment gateway integration ready
- Local Storage: Secure data persistence
- Theme Management: Dynamic theme switching
- Screen Responsiveness: flutter_screenutil integration
- Extensions: Helpful Dart extensions
- Constants: Global app constants and configurations
- Utilities: Image assets, URL management, and more
- Flutter SDK (latest stable version)
- Dart SDK
- Mason CLI
- Install Mason CLI:
dart pub global activate mason_cli- Add from BrickHub:
mason add --global mason_tdd- Generate Project:
mason make mason_tdd| Variable | Type | Description | Default |
|---|---|---|---|
name |
string | Your name | Dash |
dio |
enum | API type | get, post, noThing |
lib/
├── config/ # App configuration
│ ├── navigation/ # Navigation setup and transitions
│ ├── response/ # API response models
│ └── theme/ # Theme configuration
├── core/ # Core utilities and services
│ ├── constants/ # Global constants
│ ├── services/ # Core services (image, location, payment)
│ ├── show/ # UI feedback utilities
│ ├── utils/ # Helper utilities and extensions
│ └── widgets/ # Reusable UI components
├── data/ # Data layer
│ ├── datasources/ # Data sources (API, local)
│ ├── models/ # Data models
│ └── repositories/ # Repository implementations
├── domain/ # Domain layer
│ ├── failures/ # Error handling
│ ├── repositories/ # Repository interfaces
│ └── usecases/ # Business logic
├── features/ # Feature modules
│ ├── auth/ # Authentication features
│ ├── splash/ # Splash screen
│ └── [feature_name]/ # Custom features
└── injection_container.dart # Dependency injection setup
mason make mason_tdd_folderThis will generate a complete feature module with:
- Cubit for state management
- Page for UI
- Navigator for routing
- Initial parameters
- State definitions
// Custom Button
AppButton.getButton(
context: context,
text: 'Login',
onPressed: () => _handleLogin(),
loading: isLoading,
backgroundColor: AppColors.primary,
)
// Custom Text Field
AppTextFormField(
controller: _emailController,
hintText: 'Enter your email',
validator: (value) => EmailValidator.validate(value),
)// GET Request
final response = await networkRepository.get('/api/users');
// POST Request
final response = await networkRepository.post(
'/api/login',
data: {'email': email, 'password': password},
);The brick includes a comprehensive theming system:
// App Colors
AppColors.primary // Primary brand color
AppColors.secondary // Secondary brand color
AppColors.error // Error states
AppColors.surface // Surface colors
// Text Styles
AppTextStyles.headline1 // Large headings
AppTextStyles.body1 // Body text
AppTextStyles.caption // Small text- Splash Screen: Checks for existing user session
- Login Screen: User authentication with email/password
- Token Management: Automatic token refresh
- Secure Storage: Local storage for user data
- Navigation: Automatic routing based on auth state
Built with flutter_screenutil for responsive design:
// Responsive sizing
Container(
width: 100.w, // Responsive width
height: 50.h, // Responsive height
margin: EdgeInsets.all(16.r), // Responsive margin
)flutter_bloc- State managementget_it- Dependency injectiondio- HTTP clientfpdart- Functional programmingflutter_screenutil- Responsive designflutter_secure_storage- Local storagecached_network_image- Image caching
talker_dio_logger- Network logginglogger- Advanced loggingshimmer- Loading animationsflutter_dotenv- Environment variablesdevice_preview- UI testing (dev)
image_picker- Camera & gallerypermission_handler- Runtime permissions
Auto-detected when generating:
- Flutter: Current version
- Dart: Current version
- Java: Current version
MIT License - see LICENSE for details.
Powered by Mason 🧱