set_state_async 0.1.2
set_state_async: ^0.1.2 copied to clipboard
A mixin for avoiding State.setState during build or locking issue and improving performance.
About #
SetStateAsync is a mixin that defers multiple setState calls into one within the same event loop.
This approach helps reduce overhead when calling setState multiple times in quick succession, preventing setState() or markNeedsBuild() called during build or setState() or markNeedsBuild() called when widget tree was locked issue and improving performance.
Installation #
- Run
flutter pub add set_state_asyncto add this package to your project. - Add
import 'package:set_state_async/set_state_async.dart';to your dart file. - Add
with SetStateAsyncto yourStateclass.
Usage #
Just call setStateAsync instead of setState. An optional callback can be passed if you need to perform changes just before rebuilding the widget.
For more information, please check example or API reference.