Skip to content

A sample project that demonstrates the state management variations in Flutter

License

Notifications You must be signed in to change notification settings

suyangdong/flutter-state-management

Repository files navigation

Flutter State Management

This project is an extension of the Write your first Flutter app tutorial provided by the Flutter team, which generates random words that can be favored. This project aims to show how to manage the state of a Flutter app using state management techniques such as Vanilla Provider and BloC.

Drawing

Provider

The vanilla Provider approach involves using the Provider package to manage the application's state. In this project, we show how to use ChangeNotifier and Consumer to update the app's state.

git checkout tags/appstate

BloC

The BloC (Business Logic Component) approach involves separating the business logic of the app from the UI. In this project, we show how to use BloC to manage the app's state. We use flutter_bloc 8.0+ version, which optimizes the event handler convention. The BloC state management is on the main branch.

Unit Tests

We use bloc_test to write unit tests for BloC.

Since we uses mockito, generate the mock files before running the tests:

flutter pub run build_runner build

To run test coverage, try the following:

flutter test --coverage; genhtml coverage/lcov.info -o coverage/html; open coverage/html/index.html

Test Coverage

codecov badge

codecov badge)

Widget and Integration Tests

Widget and Integration tests are another essential part of app development. In this project, we show how to write Widget and Integration tests for the BloC approach.

Flutter Environment

Flutter 3.7.9 • channel stable

About

A sample project that demonstrates the state management variations in Flutter

Resources

License

Stars

Watchers

Forks

Packages

No packages published