-
Notifications
You must be signed in to change notification settings - Fork 3
Architecture
⚠ Warning: These infos are soon deprecated and have to be updated when the refactorings proposed in Home are completed.
The app is divided into modules, each of which has its own folder (inside app/lib/
) and is responsible for a part of the app (for example, there's a news
module and a dashboard
module).
Inside each module, there are four parts:
- The
data.dart
file defines the module's entities. Entities are classes that represent something in the domain, for exampleHomework
,NewsArticle
, etc. All entities implementEntity
and have anId<YourEntityType>
that can uniquely identify them among other entities of the same type. Also, because we use hive for data persistence, you may see entities marked with a@HiveType(typeId: TypeId.yourEntityType)
annotation. (You need to declareTypeId.yourEntityType
first insidelib/app/hive.dart
— just choose the biggest number you find there + 1). - The
routes.dart
file contains a public<module name>Routes
declaration containing all routes this module can handle. Think of routes like URLs in the browser — in fact, these are the same as those of the HPI Schul-Cloud Web-Client so users can open webpages in the app. The<module name>Routes
is then registered inlib/app/routing.dart
. - The
widgets
folder contains the widgets that this module displays or offers to other parts of the app. - The
<module name>.dart
file simply exports all the classes that are used by other modules.
The app
module takes care of stuff that's used throughout the app.
This e.g. includes Service
s — classes that handle some logic — like UserService
and ApiNetworkService
.
The app
module also provides common widgets that are used across multiple modules.
Packages are great! Whenever we see some piece of code that can be reused by other projects, we try to create a package for it.
Here are the most important packages we use:
- 💾 Data layer:
-
hive: The database we use for persisting
Entity
s. -
hive_cache: A thin wrapper around hive offering references to other
Entity
s.
-
hive: The database we use for persisting
- 🖼 UI layer:
- black_hole_flutter: A collection of frequently used widgets and extension methods.
- flutter_cached: Builds on hive_cache and offers widgets that handle loading & error states.
- flutter_deep_linking: Allows us to declare routes
- General:
-
logger: When logging stuff, use
logger.i()
(for infos, or.v()
(verbose),.e()
(error), etc.) instead ofprint
for prettier output! - time_machine: When doing anything related to date & time, use this package. It takes care of time zones, formatting, etc.
-
logger: When logging stuff, use
Need help? Feel free to contact Jonas Wanke, a former member of the Flutter team at the HPI Schul-Cloud :)