A modern Flutter application for scanning and connecting to Bluetooth Low Energy (BLE) smart devices. This app provides a clean, intuitive interface with comprehensive theming support for discovering nearby BLE devices, managing connections, and exploring device services.
- Permission Management: Automatically requests and handles Bluetooth and Location permissions (including Android 12+ BLUETOOTH_SCAN and BLUETOOTH_CONNECT permissions)
- Bluetooth Status Detection: Detects and prompts users to enable Bluetooth when disabled
- Real-time Device Scanning: Start/stop BLE scanning with real-time device discovery
- Comprehensive Device Information: Displays device name, MAC address/UUID, and signal strength (RSSI)
- Modern Search Interface: iOS-style Cupertino search field for enhanced UX
- Smart Filtering:
- Text-based filtering by device name with real-time results
- Predefined filters for device types (Audio Devices, Smartwatches)
- RSSI-based signal strength filtering
- Intuitive Navigation: Tap any device to view detailed information
- Device Information: Shows selected device's name, address, and current RSSI
- Connection Management: Connect/disconnect with real-time connection state updates
- Service Discovery: Automatic discovery of device services and characteristics upon connection
- Service/Characteristic Explorer: Expandable list showing all services with their characteristics and properties (Read, Write, Notify)
- Theme Management: Light, Dark, and System theme modes with instant switching
- BLE Configuration: Customizable scan and connection timeouts
- Scanning Preferences:
- Auto-scan on startup toggle
- Show/hide unknown devices
- Adjustable RSSI threshold slider
- Advanced Options: Auto-connect to last device, reset to defaults
- Persistent Storage: All settings saved using SharedPreferences
- Material 3 Design: Latest Material Design principles with custom theming
- Google Fonts Integration: Lato font family for consistent, professional typography
- Custom Color Scheme: Brand-aligned purple/pink color palette
- Responsive Layout: Optimized for various screen sizes
- Smooth Animations: Polished transitions and interactions
- Framework: Flutter & Dart (stable version) with Material 3
- State Management: BLoC pattern for predictable state handling
- BLE Integration: flutter_blue_plus ^1.32.12 for robust BLE operations
- Fonts: google_fonts ^6.2.1 for enhanced typography
- Storage: shared_preferences ^2.3.2 for settings persistence
- Permissions: permission_handler ^11.3.1 for platform permissions
- Architecture: Clean Architecture with feature-based organization
- Platform Support: Android and iOS with proper native configurations
- Flutter SDK (stable version)
- Android Studio / Xcode for platform-specific development
- Physical device with Bluetooth capabilities (BLE scanning requires hardware)
- Clone the repository:
git clone https://github.com/ogaroh/smart-ble.git
cd smart_ble- Install dependencies:
flutter pub get- Run the application:
For development flavor:
flutter run --flavor dev --target lib/main_dev.dartFor staging flavor:
flutter run --flavor stag --target lib/main_stag.dartFor production flavor:
flutter run --flavor prod --target lib/main_prod.dartBuild APK:
flutter build apk --flavor dev --debug --target lib/main_dev.dart
# or for release
flutter build apk --flavor prod --release --target lib/main_prod.dart- First Launch: Grant Bluetooth and Location permissions when prompted
- Scanning: Tap the scan button to discover nearby BLE devices
- Filtering: Use the search bar or filter buttons to find specific devices
- Device Connection: Tap any discovered device to view details and connect
- Settings: Access the settings via the gear icon to customize:
- Theme preference (Light/Dark/System)
- BLE timeouts and behavior
- Scanning preferences
- RSSI filtering thresholds
- CupertinoSearchTextField: Replaced standard search with iOS-style search field
- Google Fonts Integration: Implemented Lato font family across the entire app
- Comprehensive Theme System:
- Material 3 design implementation
- Custom brand colors (purple #6139F7, pink #DA79E5)
- Complete light/dark theme support with system preference detection
- Settings Screen: Full-featured configuration panel with organized sections
- Theme Control: Light/Dark/System mode switching with instant preview
- BLE Configuration: Customizable scan (5-60s) and connection timeouts
- Scanning Options: Auto-scan toggle, unknown device visibility, RSSI filtering
- Persistent Storage: SharedPreferences integration for settings persistence
- BLoC Architecture: Implemented proper state management for settings
- Clean Code: Fixed all deprecation warnings, updated to latest Material 3 APIs
- Feature Organization: Modular structure with clear separation of concerns
- Configured AndroidManifest.xml with required Bluetooth permissions
- Supports Android 12+ permission model (BLUETOOTH_SCAN, BLUETOOTH_CONNECT)
- Location permissions for BLE scanning
- Info.plist configured with Bluetooth usage descriptions
- Background modes for maintaining BLE connections
The project is configured with three flavors for different environments:
-
dev: Development environment (
SmartBLE Dev)- Package ID:
dev.ogaroh.smart_ble.dev - For development and testing
- Package ID:
-
stag: Staging environment (
SmartBLE Stag)- Package ID:
dev.ogaroh.smart_ble.stag - For pre-production testing
- Package ID:
-
prod: Production environment (
SmartBLE)- Package ID:
dev.ogaroh.smart_ble - For app store releases
- Package ID:
The application uses Flutter BLoC (Business Logic Component) pattern for predictable state management, ensuring clean separation between UI and business logic.
The app follows a clean, feature-based architecture with clear separation of concerns:
lib/
├── core/
│ ├── models/ # Domain models (BLE devices, services, characteristics)
│ ├── theme/ # App-wide theming (AppTheme, AppColors)
│ └── repositories/ # Data access layer (BLE repository)
├── features/
│ ├── ble_scan/ # BLE scanning feature
│ │ ├── bloc/ # State management (BleScanBloc)
│ │ └── view/ # UI components (BleScanScreen)
│ ├── device_detail/ # Device connection feature
│ │ ├── bloc/ # State management (DeviceDetailBloc)
│ │ └── view/ # UI components (DeviceDetailScreen)
│ └── settings/ # Settings & preferences feature
│ ├── bloc/ # State management (SettingsBloc)
│ └── view/ # UI components (SettingsScreen)
└── app.dart # App configuration with theme management
- Purpose: Manages device discovery, filtering, and scanning state
- Key Events:
StartScanEvent- Initiates BLE scanningStopScanEvent- Stops BLE scanningUpdateFilterEvent- Updates name-based filteringUpdateDeviceTypeFilterEvent- Updates device type filteringRefreshBluetoothStatusEvent- Checks permissions and BT status
- Key States:
BleScanReady- Ready to scan with discovered devicesBleScanScanning- Actively scanning for devicesBleScanPermissionsDenied- Missing required permissionsBleScanError- Error occurred during scanning
- Purpose: Manages device connection, service discovery, and characteristic operations
- Purpose: Manages app settings, theme preferences, and BLE configuration
- Key Features:
- SharedPreferences integration for persistence
- Theme mode management (Light/Dark/System)
- BLE timeout configurations
- Scanning preferences and RSSI filtering
- Key Events:
LoadSettingsEvent- Loads saved settingsUpdateThemeModeEvent- Changes app themeUpdateScanTimeoutEvent- Configures scan durationResetSettingsEvent- Restores defaults
dependencies:
flutter_blue_plus: ^1.32.12 # BLE operations
flutter_bloc: ^8.1.6 # State management
google_fonts: ^6.2.1 # Typography (Lato font)
shared_preferences: ^2.3.2 # Settings persistence
permission_handler: ^11.3.1 # Platform permissions
equatable: ^2.0.5 # Value equality
dev_dependencies:
flutter_lints: ^5.0.0 # Dart/Flutter linting
flutter_native_splash: ^2.4.4 # Splash screen generation
flavorizr: ^2.2.3 # App flavors configuration- google_fonts: Added for Lato font family integration
- shared_preferences: Added for settings persistence
- Enhanced theming: Updated to latest Material 3 APIs
- BLE Repository: Centralized BLE operations management
- Permission Handling: Android 12+ and iOS permission management
- Real-time Streams: Reactive BLE device discovery
- Connection Management: Robust connection state handling
- Bluetooth permission denials with user guidance
- Connection failure recovery and retry logic
- Service discovery error handling
- Bluetooth adapter state monitoring
- Graceful handling of unexpected disconnections
- ✅ UI Modernization: CupertinoSearchTextField, Google Fonts (Lato)
- ✅ Comprehensive Theming: Material 3 with Light/Dark/System modes
- ✅ Settings System: Complete preferences management with BLoC
- ✅ Code Quality: Fixed all deprecation warnings, updated APIs
- ✅ Architecture Enhancement: Improved separation of concerns
- Kotlin Compatibility: Updated from 1.8.22 to 2.1.0+
- Flavor Configuration: Properly configured dev/stag/prod builds
- Material 3 Migration: Updated deprecated color properties
- Performance Optimization: Efficient state management and rebuilds
- Flutter Lints: Strict linting rules for consistent code quality
- No Issues Found: All deprecation warnings resolved ✅
- Material 3 Compliance: Updated to latest design APIs
- BLoC Testing: Testable architecture for business logic
# Verify code quality
flutter analyze
# Result: No issues found! ✅
# Build verification
flutter build apk --debug
# Result: ✓ Built successfully ✅- Characteristic Operations: Read/Write/Notify functionality
- Connection History: Remember previously connected devices
- Export Functionality: Save scan results and device information
- Advanced Filtering: More sophisticated device filtering options
- Testing Suite: Comprehensive unit and widget tests
[Screenshots would be added here showing the modern UI with different themes]
Contributions are welcome! Please ensure:
- Follow the established BLoC pattern
- Maintain the feature-based architecture
- Update tests for any new functionality
- Follow Flutter/Dart style guidelines
This project is licensed under the MIT License - see the LICENSE file for details.
SmartBLE - A modern, comprehensive Flutter BLE scanner with advanced theming and settings management.
- Abstraction: UI components don't directly depend on flutter_blue_plus
- Error Handling: Centralized error handling and permission management
- Caching: Maintains discovered devices list and connection state
- Android 12+ Support: Properly handles new BLUETOOTH_SCAN and BLUETOOTH_CONNECT permissions
- iOS Compatibility: Includes required usage descriptions and handles iOS-specific requirements
- User Experience: Clear messaging when permissions are denied with retry functionality
Features follow a consistent structure:
feature/
├── bloc/ # State management
│ ├── feature_bloc.dart
│ ├── feature_event.dart
│ └── feature_state.dart
└── view/ # UI components
└── feature_screen.dart
This approach ensures:
- Scalability: Easy to add new features without affecting existing code
- Maintainability: Clear boundaries between different concerns
- Testability: Each layer can be tested independently
- Reusability: Core models and repository can be shared across features
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
[Add license information]