A Flutter application for home automation featuring a streamlined interface with a Dashboard to monitor and control devices and a Settings page to adjust user preferences.
-
Dashboard Screen:
- Control switch for devices like lights and fans.
- Display real-time data to show consumption (e.g., water, gas).
-
Settings Screen:
- Options for theme changes (light/dark mode).
- Notification settings to enable or disable notifications.
- User profile modifications (if applicable).
The app follows the MVVM (Model-View-ViewModel) pattern combined with the Provider for state management.
- Model: Represents data models (e.g.,
Device
) and data handling logic (DataService
). - View: Represents the UI layer (e.g.,
DashboardScreen
,SettingsScreen
). - ViewModel: Manages the state and business logic (
ThemeNotifier
).
The app uses the following dependencies:
-
provider: State management library for Flutter that makes it easier to manage and propagate state changes across the app.
dependencies: provider: ^6.0.0
-
shared_preferences: Flutter plugin for reading and writing simple key-value pairs. Used for persisting user settings such as theme preference and notification settings.
dependencies: shared_preferences: ^2.0.13
-
json_annotation: Provides annotations to help with JSON serialization.
dependencies: json_annotation: ^4.3.0
-
build_runner: A build system for Dart code generation that helps to run code generation tasks.
dev_dependencies: build_runner: ^2.1.7
-
json_serializable: Generates code for JSON serialization and deserialization.
dev_dependencies: json_serializable: ^6.1.4
- Flutter SDK: Install Flutter
- Dart SDK: Comes with Flutter
-
Clone the repository:
git clone https://github.com/saumysinha31/Home-Automation-System/.git cd home_automation_app
-
Install dependencies:
flutter pub get
-
Run the build runner to generate JSON serialization code:
flutter pub run build_runner build
-
Run the app:
flutter run
lib/
├── main.dart
├── models/
│ └── device.dart
├── screens/
│ ├── dashboard_screen.dart
│ └── settings_screen.dart
├── services/
│ └── data_service.dart
└── theme_notifier.dart
assets/
└── devices.json
main.dart
: Entry point of the app. Sets up the theme and navigation.theme_notifier.dart
: Manages the theme state and provides methods to toggle and persist the theme.screens/dashboard_screen.dart
: Defines the UI for the Dashboard screen, displaying device data.screens/settings_screen.dart
: Defines the UI for the Settings screen, allowing theme changes and notification toggles.models/device.dart
: Defines theDevice
data model, with JSON serialization/deserialization.services/data_service.dart
: Handles data fetching and parsing from a local JSON file (assets/devices.json
).assets/devices.json
: Simulated device data for the app.
-
Start the app: Ensure you have an emulator or physical device connected and run:
flutter run
- Fork the repository.
- Create your feature branch (
git checkout -b feature/your-feature
). - Commit your changes (
git commit -m 'Add some feature'
). - Push to the branch (
git push origin feature/your-feature
). - Open a pull request.