![]() For example, in a Todo List app, you might have a bloc for the 'Todo List' page, and a bloc for the "Add Todo" page. ![]() In reality, the point is that each logical state subject has its own bloc. In general, blocs and top-level Flutter pages have a one-to-one (1:1) relationship. Do whatever else you want, so long as you follow these rules. If you find yourself in a bloc writing if (device = browser)., then you need to reconsider. If you're importing any Flutter libraries into the bloc, then that's UI work, not business logic, and those should be moved into the UI. Inputs and outputs are sinks and streams only! No functions, no constants, no variables! (Although, you'll see that this rule is "broken" quite often to make code more concise. These rules were described in the original talk at DartConf 2018 and live in two categories: application design and UI rules. Those are broad ideas, of course, but they're made clearer by the following non-negotiable rules. This means you can use the same blocs for Flutter, AngularDart, on the server, etc. Blocs should be injectable, which means platform agnostic.Their public API consists of simple inputs and outputs only.In general, blocs are what they are for two main reasons: This in itself isn't unique, compared to other approaches, but the devil is in the details. The bloc pattern's mantra is that widgets should be as dumb as possible, and the business logic should live in separate components. Specifically at DartConf, it was presented as a nice way to share all UI logic between Flutter and AngularDart. This pattern was first revealed at Dart Conference 2018, aka DartConf, and it's purpose is to make UI business logic highly reusable. stands for Business Logic Components (or simply blocs from here on out). This text is a snippit from the book Flutter in Action, written by Eric Windmill and published by Manning Publications.ī.L.o.C. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |