A Flutter application built with GetX for state management, featuring comprehensive theming, localization, and API services.
- π¨ Dynamic Theming: Light and dark mode support with automatic color adaptation
- π Multi-language Support: Support for multiple languages with RTL support
- π GetX State Management: Complete state management solution
- π API Service: Comprehensive HTTP client with error handling
- π± Responsive Design: Adaptive UI for different screen sizes
- π― Type Safety: Full TypeScript-like type safety with Dart
- π Modular Architecture: Clean and scalable project structure
lib/
βββ core/
β βββ controllers/
β β βββ theme_controller.dart # Theme management (dark/light mode)
β β βββ language_controller.dart # Language/localization management
β βββ services/
β β βββ api_service.dart # HTTP client and API handling
β βββ theme/
β β βββ app_colors.dart # Color scheme (light/dark)
β β βββ app_text_styles.dart # Text styles with theme adaptation
β β βββ app_theme.dart # Complete theme configuration
β βββ routes/
β β βββ app_routes.dart # Route definitions and navigation
β βββ constants/
β β βββ api_constants.dart # API endpoints and constants
β βββ utils/
β βββ app_utils.dart # Utility functions and widgets
βββ features/ # Feature-based modules (to be added)
β βββ auth/
β βββ home/
β βββ profile/
β βββ settings/
βββ main.dart # App entry point
- Flutter SDK (3.6.2 or higher)
- Dart SDK
- Android Studio / VS Code
- Git
- Clone the repository:
git clone <repository-url>
cd flutter-getx-boilerplate
- Install dependencies:
flutter pub get
- Run the app:
flutter run
- get: ^4.6.6 - State management, routing, and dependency injection
- shared_preferences: ^2.2.2 - Local data persistence
- http: ^1.1.0 - HTTP client for API calls
- flutter_localizations: SDK - Internationalization support
The app uses GetX for comprehensive state management:
- Controllers: Manage business logic and state
- Reactive Programming: Automatic UI updates with
.obs
variables - Dependency Injection: Automatic controller lifecycle management
The theme system automatically adapts to light/dark mode:
// Colors automatically adapt to theme
Color primaryColor = AppColors.primary;
// Text styles automatically use correct colors
TextStyle titleStyle = AppTextStyles.titleLarge;
The API service provides a clean interface for HTTP requests:
// GET request
final response = await ApiService.to.get('/users');
// POST request
final response = await ApiService.to.post('/users', body: userData);
// Handle response
if (response.isSuccess) {
final data = response.data;
} else {
print(response.message);
}
// Get theme controller
final themeController = Get.find<ThemeController>();
// Toggle theme
themeController.toggleTheme();
// Set specific theme
themeController.setThemeMode(ThemeMode.dark);
// Check current theme
bool isDark = themeController.isDarkMode;
// Get language controller
final languageController = Get.find<LanguageController>();
// Change language
languageController.changeLanguage('es', 'ES');
// Get current language
String languageName = languageController.getCurrentLanguageName();
// Check RTL support
bool isRTL = languageController.isRTL();
// Colors automatically adapt to theme
Container(
color: AppColors.primary,
child: Text(
'Hello World',
style: AppTextStyles.headlineLarge,
),
)
// Custom text style
Text(
'Custom Text',
style: AppTextStyles.custom(
fontSize: 18,
fontWeight: FontWeight.bold,
),
)
// Simple GET request
final response = await ApiService.to.get('/api/users');
// POST with body
final response = await ApiService.to.post(
'/api/users',
body: {
'name': 'John Doe',
'email': '[email protected]',
},
);
// Handle response
if (response.isSuccess) {
AppUtils.showSuccess('Data loaded successfully');
final data = response.data;
} else {
AppUtils.showError(response.message);
}
// Show loading
AppUtils.showLoading('Loading data...');
// Hide loading
AppUtils.hideLoading();
// Show snackbars
AppUtils.showSuccess('Operation successful');
AppUtils.showError('Something went wrong');
AppUtils.showWarning('Please check your input');
AppUtils.showInfo('New feature available');
// Show confirmation dialog
final confirmed = await AppUtils.showConfirmation(
title: 'Delete Item',
message: 'Are you sure you want to delete this item?',
);
lib/features/your_feature/
βββ data/
β βββ models/
β βββ repositories/
β βββ datasources/
βββ domain/
β βββ entities/
β βββ repositories/
β βββ usecases/
βββ presentation/
βββ controllers/
βββ pages/
βββ widgets/
// In app_routes.dart
static const String yourFeature = '/your-feature';
// Add to getPages list
GetPage(
name: yourFeature,
page: () => const YourFeaturePage(),
transition: Transition.rightToLeft,
),
class YourFeatureController extends GetxController {
final _data = <String>[].obs;
List<String> get data => _data;
@override
void onInit() {
super.onInit();
loadData();
}
Future<void> loadData() async {
// Your logic here
}
}
Update the base URL in lib/core/constants/api_constants.dart
:
static const String baseUrl = 'https://your-api-url.com/v1';
Modify colors in lib/core/theme/app_colors.dart
:
static Color get primary => _themeController.isDarkMode
? const Color(0xFF64B5F6)
: const Color(0xFF1976D2);
Add new locales in lib/core/controllers/language_controller.dart
:
final _supportedLocales = <Locale>[
const Locale('en', 'US'),
const Locale('es', 'ES'),
// Add your new locale here
const Locale('your', 'CODE'),
].obs;
- Use GetX Controllers: Always use GetX controllers for state management
- Theme-Aware Colors: Always use
AppColors
instead of hardcoded colors - Consistent Text Styles: Use
AppTextStyles
for consistent typography - Error Handling: Always handle API errors gracefully
- Loading States: Show loading indicators for async operations
- Type Safety: Use proper types for all variables and functions
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
For support and questions, please open an issue in the repository or contact the development team.
Note: This is a template project structure. You can modify and extend it according to your specific requirements.