Blocs with Functional Programming: bloc_lens in Action
summary
A Dart package called bloc_lens provides composable getters/setters (lenses) for Bloc/Cubit state so widgets can read and write single nested fields immutably; examples include a number lens with min/max/step for font-size controls, a boolean lens with toggle, enum and list lenses that create new lists on update, and a tiny flutter hooks utility that subscribes only to the changed value so widgets rebuild less. An experimental block_macros generator auto-creates lenses; package is on pub.dev and GitHub.
AI-written summary · about
chapters (12)
- 0:00Introduction
- 1:09Growing state management
- 4:02What are lenses
- 6:12Introducing bloc_lens
- 9:24Practical controls with lenses
- 10:26Font size control with bloc_lens
- 12:55Performance benefits
- 14:25Use cases for bloc_lens
- 15:52Lenses with forms and widgets
- 16:59Reducing boilerplate
- 18:02Future with Dart macros
- 19:28Closing








