multi_value_listenable_builder 0.0.2 multi_value_listenable_builder: ^0.0.2 copied to clipboard
A Flutter package which allows to listening to multiple ValueListenables using a single widget.
MultiValueListenableBuilder #
A widget to listen to multiple ValueListenables in Flutter.
Usage #
-
Add the multi_value_listenable_builder as a dependency in your project.
-
Import
package:multi_value_listenable_builder/multi_value_listenable_builder.dart
in required files. -
Use
MultiValueListenableBuilder
just like any other widget.
import 'package:multi_value_listenable_builder/multi_value_listenable_builder.dart';
MultiValueListenableBuilder(
// Add all ValueListenables here.
valueListenables: [
listenable0,
listenable1,
listenable2,
.
.
listenableN
],
builder: (context, values, child) {
// Get the updated value of each listenable
// in values list.
return YourWidget(
values.elementAt(0),
values.elementAt(1),
values.elementAt(2),
.
.
values.elementAt(N),
child: child // Optional child.
);
},
child: YourOptionalChildWidget(),
)
A detailed and working example can be found here.