A secure authentication application using Flutter with MySQL database connection.
- Features
- Setup
- Database Configuration
- Authentication Structure
- Theme Structure
- Language Management
- Error Handling
- Security
- Architecture
- Folder Structure
- π Secure MySQL connection
- π Encryption MYSQL Information
- π Authentication (Login/Register)
- π NetworkControl/DatabaseControl/Login Control (Splash Screen)
- π Password encryption with BCrypt
- π TR/EN language support
- π¨ Customizable theme
- π± Responsive design
- β‘ Performance optimization
β’ Flutter SDK (>=3.2.3)
β’ MySQL Server
β’ MySQL Workbench (recommended)
-
Clone the project:
git clone https://github.com/RecLast/FlutterMysqlConnect.git -
Install dependencies:
flutter pub get
CREATE DATABASE flutter_mysql_connect;
CREATE TABLE users (
id INT PRIMARY KEY AUTO_INCREMENT,
username VARCHAR(50) UNIQUE NOT NULL,
email VARCHAR(100) UNIQUE NOT NULL,
password VARCHAR(255) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
To configure MySQL connection information securely:
-
Edit
lib/core/utils/config_generator.dartfile:final config = { 'host': 'localhost', 'port': '3306', 'user': 'your_username', 'password': 'your_password', 'db': 'your_database' }; -
Run the config generator:
dart run lib/core/utils/config_generator.dart -
Generated encrypted config file:
assets/config/db_config.enc
::: info π Security: Connection information is protected with XOR encryption and SHA-256. :::
The authentication system is configured under features/auth with MVVM
architecture:
features/auth/
βββ model/
β βββ user_model.dart # User data model
βββ view/
β βββ sign_view.dart # Login/Register screen
β βββ splash_view.dart # Splash screen
βββ viewmodel/
βββ auth_view_model.dart # Authentication business logic
- Session check in splash screen
- Login/Register form validation
- Password hashing with BCrypt
- JWT token management
Theme management is centrally configured under core/theme:
core/theme/
βββ app_colors.dart # Color palettes
βββ app_text_styles.dart # Typography styles
βββ app_theme.dart # Theme configuration
::: info π‘ Customization: All colors and styles can be managed from a single point. :::
// Color usage
color: AppColors.darkBlue['primary']
// Text style usage
style: AppTextStyles.ubuntuBold.copyWith(
fontSize: 24,
color: Colors.white,
)
Multi-language support is configured under core/init/lang:
core/init/lang/
βββ locale_keys.dart # Language keys
βββ locale_manager.dart # Language manager
βββ translations/ # Language files
βββ tr.json
βββ en.json
// Change language
LocaleManager.instance.setLocale(const Locale('en', 'US'));
// Text translation
Text(LocaleKeys.welcome.tr())
Central error management is configured under core/base:
core/base/
βββ error/
β βββ base_error.dart # Base error class
β βββ network_error.dart # Network errors
β βββ database_error.dart # Database errors
βββ result/
βββ result_model.dart # Result model
try {
await operation();
} on NetworkError catch (e) {
showErrorDialog(e.message);
} on DatabaseError catch (e) {
logError(e);
showErrorSnackbar(e.message);
}
::: warning π Error Tracking: All errors are centrally logged and appropriate messages are shown to the user. :::
- Secure password hashing with BCrypt
- Sensitive data encryption with AES-256
- Secure connection with SSL/TLS
// Unsafe Usage β
"SELECT * FROM users WHERE username = '$username'"
// Safe Usage β
"SELECT * FROM users WHERE username = ?"
The project is developed using MVVM (Model-View-ViewModel) architecture:
- Model: Data structures and database operations
- View: UI components
- ViewModel: Business logic and state management
lib/
βββ core/
β βββ init/
β β βββ database/ # MySQL connection management
β β βββ encryption/ # Encryption services
β β βββ lang/ # Language management
β βββ services/ # General services
β βββ theme/ # Theme configuration
β βββ utils/ # Helper utilities
βββ features/
βββ auth/ # Authentication
β βββ model/
β βββ view/
β βββ viewmodel/
βββ home/ # Home page
βββ model/
βββ view/
βββ viewmodel/
::: info π‘ Tip: Visit our Wiki page for detailed code examples and API documentation. :::
For questions and suggestions: iletisim@umiteski.com.tr
Β© 2025 Flutter MySQL Connect. Developed by Γmit Eski. Licensed under MIT License.
