MultiValueListenableBuilder
A widget to listen to multiple ValueListenable s in Flutter.
Reason for the fork
This is fork-and-rewrap of the the original multi_value_listenable_builder package. This aims to provide type-safety, instead of using dynamic listneables, that need type-casting at the time of builder definition.
Available type-safe variants:
Usage
-
Add the multi_value_listenable_builder as a dependency in your project.
-
Import
package:multi_value_listenable_builder_typed/multi_value_listenable_builder_typed.dart
in required files. -
Use the typed variants for typed callbacks.
-
Use
MultiValueListenableBuilder
, for more listenable, just like any other widget.
import 'package:multi_value_listenable_builder_typed/multi_value_listenable_builder_typed.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.