This project is a practical experiment to better understand how Streams work with Floor (a SQLite persistence library for Flutter) and how to use both StreamProvider and AsyncNotifierProvider with Riverpod.
- Observe how Floor emits changes reactively using DAOs that return
Stream<List<T>>. - Compare
StreamProviderandAsyncNotifierProviderfor managing data in Flutter. - Explore how inheritance affects data modeling and UI logic.
- Analyze how to structure reactive screens based on different data sources.
This app defines two main entities:
Teacher: a simple class with no inheritance.TeacherExtends: a class that extends a baseUserclass.
For each entity, the app includes 3 screens:
- Contains a search bar to filter teachers by name.
- Uses
StreamProviderto reactively display results as Floor emits data changes.
- Shows a list of teachers that updates in real time.
- Includes a
FloatingActionButtonto add new teachers. - Powered by a
StreamProviderthat listens to the Floor DAO.
- Shows a list of teachers using an
AsyncNotifier. - This list does not update automatically when new teachers are added.
- The notifier loads data only once via a
Futurewhen initialized. - Designed to contrast with the real-time behavior of the
StreamProviderscreen.
π§ͺ This setup allows you to clearly see how
StreamProviderreacts to database changes whileAsyncNotifierrequires explicit state updates.
The app uses a side drawer menu that lets you switch between:
- Screens for
Teacher - Screens for
TeacherExtends
Although much of the code could be reused (e.g. through inheritance or extensions), the UI was deliberately split to highlight differences between a simple class and an inherited one.
- Flutter
- Floor β SQLite persistence
- Riverpod β state management
This project acts as a sandbox to understand:
- When to use
StreamProviderfor live updates - When
AsyncNotifieris more appropriate - How Floor manages data reactivity through DAO streams
- How inheritance impacts model structure and UI implementation
This project is intended as a personal learning tool and technical demo. Itβs not a production-ready app, but a minimal and focused experiment on reactive data handling in Flutter using Floor and Riverpod.
βΉοΈ This project includes generated files like
database.g.dartfor ease of use and to avoid running code generation manually.
lib
βββ application
βββ data
βΒ Β βββ datasources
βΒ Β βΒ Β βββ db
βΒ Β βΒ Β βββ dao
βΒ Β βΒ Β βΒ Β βββ teacher_dao.dart
βΒ Β βΒ Β βΒ Β βββ teacherextends_dao.dart
βΒ Β βΒ Β βββ database.dart
βΒ Β βΒ Β βββ database.g.dart
βΒ Β βΒ Β βββ database_service.dart
βΒ Β βββ repository
βΒ Β βββ teacher_db.dart
βΒ Β βββ teacherextends_db.dart
βββ domain
βΒ Β βββ entities
βΒ Β βΒ Β βββ teacher.dart
βΒ Β βΒ Β βββ teacher_extends.dart
βΒ Β βββ models
βΒ Β βββ user.dart
βββ main.dart
βββ presentation
βΒ Β βββ providers
βΒ Β βΒ Β βββ database.dart
βΒ Β βΒ Β βββ teacher
βΒ Β βΒ Β βΒ Β βββ teacher_async_notifier.dart
βΒ Β βΒ Β βΒ Β βββ teacher_repository.dart
βΒ Β βΒ Β βΒ Β βββ teacher_stream.dart
βΒ Β βΒ Β βββ teacherextends
βΒ Β βΒ Β βββ teacherext_async_notifier.dart
βΒ Β βΒ Β βββ teacherext_repository.dart
βΒ Β βΒ Β βββ teacherext_stream.dart
βΒ Β βββ screens
βΒ Β βΒ Β βββ form.dart
βΒ Β βΒ Β βββ home_drawer.dart
βΒ Β βΒ Β βββ teacher
βΒ Β βΒ Β βΒ Β βββ teacher_async.dart
βΒ Β βΒ Β βΒ Β βββ teacher_list.dart
βΒ Β βΒ Β βΒ Β βββ teacher_search.dart
βΒ Β βΒ Β βΒ Β βββ teacher_stream.dart
βΒ Β βΒ Β βββ teacherextends
βΒ Β βΒ Β βββ teacherext_async.dart
βΒ Β βΒ Β βββ teacherext_list.dart
βΒ Β βΒ Β βββ teacherext_search.dart
βΒ Β βΒ Β βββ teacherext_stream.dart
βΒ Β βββ widgets
βΒ Β βββ navigation_bar.dart
βΒ Β βββ save_form_button.dart
βΒ Β βββ search_bar.dart
βΒ Β βββ teacher_widget.dart
βββ shared
βββ utils
βββ constants.dart
Pull requests, ideas, or feedback are welcome!
Aquest projecte és una prova per entendre millor com funcionen els Streams amb Floor i les diferències entre StreamProvider i AsyncNotifierProvider amb Riverpod.
- Comprovar com Floor emet canvis reactius usant DAOs que retornen
Stream<List<T>>. - Comparar el comportament entre
StreamProvideriAsyncNotifierProvider. - Explorar la diferΓ¨ncia entre models amb i sense herΓ¨ncia a nivell de dades i interfΓcie.
- Analitzar com es poden estructurar pantalles que reaccionen a dades en temps real.
El projecte contΓ© dues entitats principals:
Teacher: una classe simple sense herència.TeacherExtends: una classe que hereta deUser.
Per a cada entitat hi ha 3 pantalles:
- Inclou una barra de cerca per filtrar professors pel nom.
- Utilitza
StreamProviderper mostrar resultats de forma reactiva a mesura que Floor emet canvis.
- Mostra una llista de professors actualitzada en temps real.
- TΓ© un
FloatingActionButtonper afegir nous professors. - Es basa en un
StreamProviderconnectat al DAO de Floor.
- Mostra una llista de professors, perΓ² no sβactualitza automΓ ticament.
- El
AsyncNotifiernomΓ©s carrega dades en la inicialitzaciΓ³ viaFuture. - Permet comparar amb la pantalla basada en
StreamProvider.
π§ͺ AixΓ² permet veure clarament com
StreamProviderreacciona als canvis a la base de dades, mentre queAsyncNotifiernecessita una actualitzaciΓ³ manual.
El drawer de l'aplicaciΓ³ permet escollir entre:
- UI basada en
Teacher - UI basada en
TeacherExtends
Tot i que es podria haver fet reutilització de codi, s'ha optat per mantenir les pantalles separades per fer evident la diferència entre una classe simple i una amb herència.
- Flutter
- Floor β per a persistΓ¨ncia amb SQLite
- Riverpod β per a gestiΓ³ d'estat
Aquest projecte serveix com a sandbox per entendre:
- Quan Γ©s millor fer servir
StreamProvider - Quan tΓ© sentit controlar lβestat amb
AsyncNotifier - Com Floor gestiona reactivitat amb DAOs
- Com estructurar models amb i sense herència
βΉοΈ Este projecte inclou arxius generats com
database.g.dartper facilitat i per a evitar executar generaciΓ³ de codi manualment.
lib
βββ application
βββ data
βΒ Β βββ datasources
βΒ Β βΒ Β βββ db
βΒ Β βΒ Β βββ dao
βΒ Β βΒ Β βΒ Β βββ teacher_dao.dart
βΒ Β βΒ Β βΒ Β βββ teacherextends_dao.dart
βΒ Β βΒ Β βββ database.dart
βΒ Β βΒ Β βββ database.g.dart
βΒ Β βΒ Β βββ database_service.dart
βΒ Β βββ repository
βΒ Β βββ teacher_db.dart
βΒ Β βββ teacherextends_db.dart
βββ domain
βΒ Β βββ entities
βΒ Β βΒ Β βββ teacher.dart
βΒ Β βΒ Β βββ teacher_extends.dart
βΒ Β βββ models
βΒ Β βββ user.dart
βββ main.dart
βββ presentation
βΒ Β βββ providers
βΒ Β βΒ Β βββ database.dart
βΒ Β βΒ Β βββ teacher
βΒ Β βΒ Β βΒ Β βββ teacher_async_notifier.dart
βΒ Β βΒ Β βΒ Β βββ teacher_repository.dart
βΒ Β βΒ Β βΒ Β βββ teacher_stream.dart
βΒ Β βΒ Β βββ teacherextends
βΒ Β βΒ Β βββ teacherext_async_notifier.dart
βΒ Β βΒ Β βββ teacherext_repository.dart
βΒ Β βΒ Β βββ teacherext_stream.dart
βΒ Β βββ screens
βΒ Β βΒ Β βββ form.dart
βΒ Β βΒ Β βββ home_drawer.dart
βΒ Β βΒ Β βββ teacher
βΒ Β βΒ Β βΒ Β βββ teacher_async.dart
βΒ Β βΒ Β βΒ Β βββ teacher_list.dart
βΒ Β βΒ Β βΒ Β βββ teacher_search.dart
βΒ Β βΒ Β βΒ Β βββ teacher_stream.dart
βΒ Β βΒ Β βββ teacherextends
βΒ Β βΒ Β βββ teacherext_async.dart
βΒ Β βΒ Β βββ teacherext_list.dart
βΒ Β βΒ Β βββ teacherext_search.dart
βΒ Β βΒ Β βββ teacherext_stream.dart
βΒ Β βββ widgets
βΒ Β βββ navigation_bar.dart
βΒ Β βββ save_form_button.dart
βΒ Β βββ search_bar.dart
βΒ Β βββ teacher_widget.dart
βββ shared
βββ utils
βββ constants.dart
El projecte ha estat dissenyat com a eina dβaprenentatge i exploraciΓ³ personal. No pretΓ©n ser una aplicaciΓ³ completa, sinΓ³ una base per entendre millor les eines i patrons.
Les millores, idees o pull requests sΓ³n benvingudes!