12. Wrap-up

What we’ve built

What we built

flowchart LR
  subgraph UI["UI layer"]
    V["View"] --> VM["ViewModel"]
  end
  subgraph Domain["Domain layer"]
    UC["SaveSessionUseCase"] --> A["MotionAnalyzer"]
  end
  subgraph Data["Data layer"]
    R["Repository"] --> DB[("drift")]
    S["ImuDevice<br/>Fake / BLE"]
    P[("shared_preferences")]
  end
  C["ImuConnection<br/>connection, battery"]
  VM --> UC
  VM --> R
  UC --> R
  VM -- "ref.listen" --> S
  C --> S
  C -. "saved ID" .-> P
  V -- "ref.watch" --> C

Things to remember

State

  • State uses freezed; update with copyWith
  • After await, check ref.mounted

Subscriptions

  • Streams go into a StreamProvider
  • ref.listen once in build
  • Limit the screen update rate

App-wide state

  • Exactly one, in a keepAlive Notifier
  • Screens only read via ref.watch / select
  • Communication happens inside the provider

Data

  • Queries only in Repositories
  • Business rules go to the domain layer

UI text

  • Use context.t in Widgets
  • Keep UI text out of ViewModels

Next steps

  1. Plot the angular velocity during measurement (fl_chart, etc.)
  2. Save the language setting in shared_preferences and restore it on the next launch
  3. Export raw data to CSV and share it
  4. Run flutter analyze and flutter test automatically in CI

Final check

CHECK 0 / 2