Binder – using scopes to separate business logic
Binder, just like any popular state management solution, aims to separate business logic from the main UI code, which makes it easier to manage, read, test, and update the code. Binder uses states and scopes to manage and separate business logic from the UI. Let's add the package dependency for Binder and create our counter example application.
Adding a Binder dependency in a sample application
Create a new application using any name you want, just like we did in the previous chapters:
flutter create any_name_you_wish
You will get the same counter example application with the default setState
management technique implemented to update the counter value.
Let's see how to embed Binder into your application code:
- Open up a browser and go to https://pub.dev/.
- Type
binder
in the search bar and hit Enter. - Click on binder. It looks something like this: