Skip to content

RecLast/FlutterMysqlConnect

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

13 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Flutter MySQL Connect

A secure authentication application using Flutter with MySQL database connection.

Flutter MySQL Connect

πŸ“‘ Contents

✨Features

  • πŸ” 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

βš™οΈSetup

Requirements

β€’ Flutter SDK (>=3.2.3)
β€’ MySQL Server
β€’ MySQL Workbench (recommended)

Steps

  1. Clone the project:

    git clone https://github.com/RecLast/FlutterMysqlConnect.git
    
  2. Install dependencies:

    flutter pub get
    

πŸ’ΎDatabase Configuration

1. Create Database

CREATE DATABASE flutter_mysql_connect;

2. Table Structure

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
);

3. Secure Connection Configuration

To configure MySQL connection information securely:

  1. Edit lib/core/utils/config_generator.dart file:

    final config = {
        'host': 'localhost',
        'port': '3306',
        'user': 'your_username',
        'password': 'your_password',
        'db': 'your_database'
    };
    
  2. Run the config generator:

    dart run lib/core/utils/config_generator.dart
    
  3. Generated encrypted config file: assets/config/db_config.enc

::: info πŸ” Security: Connection information is protected with XOR encryption and SHA-256. :::

πŸ”‘Authentication Structure

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

Authentication Flow

  1. Session check in splash screen
  2. Login/Register form validation
  3. Password hashing with BCrypt
  4. JWT token management

🎨Theme Structure

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. :::

Theme Usage

// Color usage
color: AppColors.darkBlue['primary']

// Text style usage
style: AppTextStyles.ubuntuBold.copyWith(
    fontSize: 24,
    color: Colors.white,
)

🌍Language Management

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

Language Usage

// Change language
LocaleManager.instance.setLocale(const Locale('en', 'US'));

// Text translation
Text(LocaleKeys.welcome.tr())

⚠️Error Handling

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

Error Handling Usage

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. :::

πŸ”’Security

Encryption

  • Secure password hashing with BCrypt
  • Sensitive data encryption with AES-256
  • Secure connection with SSL/TLS

SQL Injection Protection

// Unsafe Usage ❌
"SELECT * FROM users WHERE username = '$username'"

// Safe Usage βœ…
"SELECT * FROM users WHERE username = ?"

πŸ—οΈ Architecture

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

πŸ“Folder Structure

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. :::

πŸ“ž Contact

For questions and suggestions: iletisim@umiteski.com.tr

© 2025 Flutter MySQL Connect. Developed by Ümit Eski. Licensed under MIT License.

Releases

Packages

Used by

Contributors

Languages