Template Structure
Understanding the organization and architecture of our Flutter template
Flutter Template Structure
Our Flutter template comes with a clean, intuitive structure that serves as a foundation for your application. This guide will help you understand the initial structure and how to build upon it as your app grows.
Initial Directory Structure
Core Directories Explained
1. lib/ Directory
The lib/
directory contains all your Dart code and is organized into logical sections:
common/
Contains shared utilities and constants used throughout the app:
constants.dart
- App-wide constants including:- String constants
- Numeric values
- Configuration settings
- API endpoints (if applicable)
pages/
Houses all the screen/page widgets of your application:
onboarding_screen.dart
- The initial onboarding experience for users- Additional pages will be added here as your app grows
styles/
Contains styling-related configurations:
theme.dart
- Defines your app’s visual theme including:- Color schemes
- Text styles
- Widget themes
- Custom theme extensions
main.dart
The entry point of your application, responsible for:
- App initialization
- Theme setup
- Initial route configuration
- Global providers/services setup
2. test/ Directory
Contains all test files, organized to mirror the lib/ directory structure:
- Unit tests
- Widget tests
- Integration tests
3. assets/ Directory
Stores all static assets:
images/
- Image filesfonts/
- Custom fontsicons/
- App icons
4. Platform-Specific Directories
android/
Contains Android-specific configuration:
- Gradle configuration
- Android manifest
- Resource files
- Platform-specific code
ios/
Houses iOS-specific configuration:
- Xcode project files
- Info.plist
- Resource files
- Platform-specific code
Key Configuration Files
pubspec.yaml
The central configuration file that defines:
- App metadata
- Dependencies
- Asset declarations
- Flutter SDK version
Example:
Best Practices for Growing Your App
As your application grows, consider these organizational practices:
-
Expanding the Structure
- Create new directories as needed (e.g.,
widgets/
,services/
,models/
) - Group related features in feature-specific directories
- Keep the file structure shallow and intuitive
- Create new directories as needed (e.g.,
-
Code Organization
- Place reusable widgets in a
widgets/
directory - Create a
models/
directory for data models - Add a
services/
directory for business logic - Consider a
utils/
directory for helper functions
- Place reusable widgets in a
-
Asset Management
- Use descriptive names for assets
- Organize assets by feature or type
- Follow Flutter’s asset naming conventions
-
Testing Strategy
- Create tests alongside new features
- Maintain test coverage for critical functionality
- Group tests logically matching the source structure
Next Steps
Now that you understand the initial template structure, you can:
- Start building your first screens in the
pages/
directory - Add custom themes and styles in
styles/theme.dart
- Define app-wide constants in
common/constants.dart
- Begin adding your application’s unique features
For more detailed information about specific aspects of the template, refer to: