# musabshaikhh/flutter_switch_on-off_ui architecture

> Architecture diagram of the GitHub repository musabshaikhh/flutter_switch_on-off_ui, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/musabshaikhh/flutter_switch_on-off_ui
- Repository: https://github.com/musabshaikhh/flutter_switch_on-off_ui

## Overview

1. **Repository shape**
   - This is a Flutter cross-platform UI app, with one shared Dart codebase under `lib/` and thin platform shells for Android, iOS, and Web.
   - The architecture is primarily a presentation-layer app: no backend, persistence layer, or network integration is present in the repo.

2. **Main user flow**
   - The app starts on a login screen.
   - Pressing **Sign In** navigates to a home dashboard.
   - A logout action returns the user to the login screen.
   - The navigation behavior is part of the UI architecture, not authentication logic; there is no real auth service in the repository.

3. **Entry point and app bootstrapping**
   - `lib/main.dart` is the app entry point and likely sets the initial route to `LoginPage`.
   - Platform launch code is standard Flutter boilerplate:
     - Android: `android/app/src/main/.../MainActivity.kt`
     - iOS: `ios/Runner/AppDelegate.swift` and `SceneDelegate.swift`
     - Web: `web/index.html` and `web/manifest.json`
   - These platform files mainly host the Flutter runtime rather than implement app-specific behavior.

4. **Screen-level composition**
   - `lib/pages/login_page.dart` contains the login UI and its form-like interaction.
   - `lib/pages/home_page.dart` contains the dashboard with greeting header, device section, and grid layout.
   - These pages are the top-level feature boundaries in the shared app code.

5. **Reusable UI components**
   - `lib/components/my_button.dart` encapsulates the Sign In button and the page transition behavior.
   - `lib/components/my_textfield.dart` encapsulates the styled text input fields used on the login screen.
   - `lib/util/smart_device_box.dart` encapsulates a single smart-device card, including icon, label, and toggle state rendering.
   - This separates repeated styling and interaction patterns from page composition.

6. **Device control subsystem**
   - The home dashboard centers on a 2×2 grid of smart-device cards.
   - Each card represents one device state, with defaults described in the README:
     - Smart Light: ON
     - Smart AC: OFF
     - Smart TV: OFF
     - Smart Fan: OFF
   - State changes are reflected immediately in the card appearance, so the primary data flow here is local UI state driving conditional styling.

7. **Interaction and state flow**
   - Login inputs feed into a visual-only sign-in action.
   - On the home page, toggle switches update device card state locally and redraw the widget tree.
   - Logout uses replacement navigation, which removes the home page from the back stack and restores the login screen as the current root view.
   - The app appears to rely on Flutter widget state rather than an external state management package.

8. **Navigation and transitions**
   - Screen changes use custom slide animations via `PageRouteBuilder` and `SlideTransition`.
   - Sign-in transitions the home page in from the right.
   - Logout transitions the login page in from the left.
   - This gives the navigation layer a distinct visual behavior without introducing a separate routing framework.

9. **Styling and asset usage**
   - The UI uses Flutter widget styling plus app assets for icons and device imagery.
   - Assets live under `lib/assets` according to the README, while platform launch and icon assets are stored in the Android, iOS, and Web directories.
   - `google_fonts` is used for the large heading typography, and `CupertinoSwitch` provides the iOS-style toggles.

10. **Platform packaging and build boundaries**
   - Android and iOS directories contain the native wrappers, manifest/configuration files, and launch resources required to ship the Flutter app on those platforms.
   - The web folder contains the browser shell and PWA metadata.
   - These directories are infrastructure boundaries; the actual product behavior remains in the shared Flutter layer.

11. **Testing and quality**
   - `test/widget_test.dart` indicates at least one Flutter widget test exists.
   - `analysis_options.yaml` suggests standard Dart linting and static analysis are enabled.
   - `pubspec.yaml` / `pubspec.lock` define dependencies and asset/package resolution.

12. **Architectural summary for a diagram**
   - Draw a single shared Flutter UI core composed of `main.dart` → login page → home page.
   - Under that core, show reusable UI components feeding both screens.
   - Show local state flowing into widget rendering and navigation events flowing between pages.
   - Surround the core with thin platform shells for Android, iOS, and Web, plus assets and tests as supporting concerns.

Main entry points: [`lib/main.dart`](https://github.com/musabshaikhh/flutter_switch_on-off_ui/blob/main/lib/main.dart) (main.dart), [`lib/pages/home_page.dart`](https://github.com/musabshaikhh/flutter_switch_on-off_ui/blob/main/lib/pages/home_page.dart) (Home Page), [`lib/pages/login_page.dart`](https://github.com/musabshaikhh/flutter_switch_on-off_ui/blob/main/lib/pages/login_page.dart) (Login Page), [`lib/components/my_button.dart`](https://github.com/musabshaikhh/flutter_switch_on-off_ui/blob/main/lib/components/my_button.dart) (Button)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_shared_flutter["Shared Flutter UI"]
  node_main["main.dart<br/>entrypoint<br/>[main.dart]"]
  node_login_page["Login Page<br/>screen<br/>[login_page.dart]"]
  node_home_page["Home Page<br/>screen<br/>[home_page.dart]"]
  node_my_button["Button<br/>[my_button.dart]"]
  node_my_textfield["Text Field<br/>[my_textfield.dart]"]
  node_smart_device_box["Device Card"]
  node_login_state(("Login State<br/>ui state"))
  node_device_state(("Device State<br/>ui state"))
  node_navigation(("Navigation<br/>route transitions"))
end

subgraph group_platform_shells["Platform Shells"]
  node_android_shell["Android<br/>platform shell<br/>[MainActivity.kt]"]
  node_ios_shell["iOS<br/>platform shell<br/>[AppDelegate.swift]"]
  node_web_shell["Web<br/>platform shell<br/>[index.html]"]
end

subgraph group_supporting["Supporting Files"]
  node_assets[("Assets<br/>resource pack")]
  node_tests["Widget Tests<br/>[widget_test.dart]"]
  node_config["Config<br/>tooling<br/>[pubspec.yaml]"]
end

node_main -->|"starts at"| node_login_page
node_login_page -->|"uses"| node_my_textfield
node_login_page -->|"uses"| node_my_button
node_my_textfield -->|"updates"| node_login_state
node_my_button -->|"triggers"| node_navigation
node_navigation -->|"opens"| node_home_page
node_home_page -->|"uses"| node_smart_device_box
node_smart_device_box -->|"renders"| node_device_state
node_home_page -->|"logout"| node_navigation
node_home_page -->|"controls"| node_device_state
node_main -.->|"hosts"| node_android_shell
node_main -.->|"hosts"| node_ios_shell
node_main -.->|"hosts"| node_web_shell
node_login_page -.->|"uses"| node_assets
node_home_page -.->|"uses"| node_assets
node_main -.->|"defined by"| node_config
node_main -.->|"verified by"| node_tests

click node_main "https://github.com/musabshaikhh/flutter_switch_on-off_ui/blob/main/lib/main.dart"
click node_login_page "https://github.com/musabshaikhh/flutter_switch_on-off_ui/blob/main/lib/pages/login_page.dart"
click node_home_page "https://github.com/musabshaikhh/flutter_switch_on-off_ui/blob/main/lib/pages/home_page.dart"
click node_my_button "https://github.com/musabshaikhh/flutter_switch_on-off_ui/blob/main/lib/components/my_button.dart"
click node_my_textfield "https://github.com/musabshaikhh/flutter_switch_on-off_ui/blob/main/lib/components/my_textfield.dart"
click node_smart_device_box "https://github.com/musabshaikhh/flutter_switch_on-off_ui/blob/main/lib/util/smart_device_box.dart"
click node_android_shell "https://github.com/musabshaikhh/flutter_switch_on-off_ui/blob/main/android/app/src/main/kotlin/com/example/flutter_application_1/MainActivity.kt"
click node_ios_shell "https://github.com/musabshaikhh/flutter_switch_on-off_ui/blob/main/ios/Runner/AppDelegate.swift"
click node_web_shell "https://github.com/musabshaikhh/flutter_switch_on-off_ui/blob/main/web/index.html"
click node_assets "https://github.com/musabshaikhh/flutter_switch_on-off_ui/tree/main/lib/assets"
click node_tests "https://github.com/musabshaikhh/flutter_switch_on-off_ui/blob/main/test/widget_test.dart"
click node_config "https://github.com/musabshaikhh/flutter_switch_on-off_ui/blob/main/pubspec.yaml"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main,node_login_page,node_home_page,node_my_button,node_my_textfield,node_smart_device_box,node_login_state,node_device_state,node_navigation toneBlue
class node_android_shell,node_ios_shell,node_web_shell toneAmber
class node_assets,node_tests,node_config toneMint
```

## Components

### Shared Flutter UI

Primary Dart application and reusable UI in lib/.

- [main.dart](https://github.com/musabshaikhh/flutter_switch_on-off_ui/blob/main/lib/main.dart): entrypoint · App bootstrap and initial route setup. · `lib/main.dart`
- [Login Page](https://github.com/musabshaikhh/flutter_switch_on-off_ui/blob/main/lib/pages/login_page.dart): screen · Login UI and sign-in interaction. · `lib/pages/login_page.dart`
- [Home Page](https://github.com/musabshaikhh/flutter_switch_on-off_ui/blob/main/lib/pages/home_page.dart): screen · Dashboard with greeting, device section, and grid layout. · `lib/pages/home_page.dart`
- [Button](https://github.com/musabshaikhh/flutter_switch_on-off_ui/blob/main/lib/components/my_button.dart): Reusable sign-in button and page transition trigger. · `lib/components/my_button.dart`
- [Text Field](https://github.com/musabshaikhh/flutter_switch_on-off_ui/blob/main/lib/components/my_textfield.dart): Styled text input used on the login screen. · `lib/components/my_textfield.dart`
- [Device Card](https://github.com/musabshaikhh/flutter_switch_on-off_ui/blob/main/lib/util/smart_device_box.dart): Reusable smart-device card with icon, label, and toggle state. · `lib/util/smart_device_box.dart`
- **Login State**: ui state · Local form input state driving the sign-in flow.
- **Device State**: ui state · Local toggle state for the smart-device cards.
- **Navigation**: route transitions · Custom slide transitions between login and home.

### Platform Shells

Thin Android, iOS, and Web wrappers around the Flutter app.

- [Android](https://github.com/musabshaikhh/flutter_switch_on-off_ui/blob/main/android/app/src/main/kotlin/com/example/flutter_application_1/MainActivity.kt): platform shell · Native Android wrapper and launch host for Flutter. · `android/app/src/main/kotlin/com/example/flutter_application_1/MainActivity.kt`
- [iOS](https://github.com/musabshaikhh/flutter_switch_on-off_ui/blob/main/ios/Runner/AppDelegate.swift): platform shell · Native iOS runner and app lifecycle host. · `ios/Runner/AppDelegate.swift`
- [Web](https://github.com/musabshaikhh/flutter_switch_on-off_ui/blob/main/web/index.html): platform shell · Browser entry shell and PWA metadata. · `web/index.html`

### Supporting Files

Assets, tests, and repo-level configuration around the app.

- [Assets](https://github.com/musabshaikhh/flutter_switch_on-off_ui/tree/main/lib/assets): resource pack · App images and visual resources used by the UI. · `lib/assets`
- [Widget Tests](https://github.com/musabshaikhh/flutter_switch_on-off_ui/blob/main/test/widget_test.dart): test · Flutter widget test coverage for the UI. · `test/widget_test.dart`
- [Config](https://github.com/musabshaikhh/flutter_switch_on-off_ui/blob/main/pubspec.yaml): tooling · Dependencies, linting, and build configuration. · `pubspec.yaml`

## Connections

- main.dart → Login Page: starts at · Bootstraps the app into the login screen.
- Login Page → Text Field: uses · Composes the login form from reusable text inputs.
- Login Page → Button: uses · Renders the sign-in action with a reusable button.
- Text Field → Login State: updates · Collects local input state from the form.
- Button → Navigation: triggers · Initiates the slide transition into the home page.
- Navigation → Home Page: opens · Routes the user to the dashboard after sign-in.
- Home Page → Device Card: uses · Builds the device grid from reusable cards.
- Device Card → Device State: renders · Reflects local toggle state in each card.
- Home Page → Navigation: logout · Returns to the login page with a reverse transition.
- Home Page → Device State: controls · Updates device states locally when switches change.
- main.dart → Android: hosts · Runs inside the Android Flutter wrapper.
- main.dart → iOS: hosts · Runs inside the iOS Flutter wrapper.
- main.dart → Web: hosts · Runs inside the web shell.
- Login Page → Assets: uses · Renders UI assets and imagery.
- Home Page → Assets: uses · Uses visual assets for the dashboard.
- main.dart → Config: defined by · App structure is governed by dependencies and project config.
- main.dart → Widget Tests: verified by · Widget behavior is covered by test scaffolding.
