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 while widget is building or locked" issue and improving performance.

Installation

  1. Run the following command in your project directory:
flutter pub add set_state_async
  1. Add the following code to your dart file:
import 'package:set_state_async/set_state_async.dart';
  1. Add SetStateAsync mixin to your State class:
class _MyWidgetState extends State<MyWidget> with SetStateAsync {
	// ...
}

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.

Libraries

set_state_async