live WEB search
This commit is contained in:
parent
47945dbec7
commit
4ade7f1682
19 changed files with 503 additions and 59 deletions
|
@ -0,0 +1,34 @@
|
|||
import 'package:flutter/foundation.dart' show Listenable, ValueListenable;
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
/// This widget listens to multiple [ValueListenable]s and calls given builder function if any one of them changes.
|
||||
class MultiValueListenableBuilder extends StatelessWidget {
|
||||
const MultiValueListenableBuilder({
|
||||
required this.valueListenables,
|
||||
required this.builder,
|
||||
this.child,
|
||||
super.key,
|
||||
}) : assert(valueListenables.length != 0);
|
||||
|
||||
/// List of [ValueListenable]s to be listened to.
|
||||
final List<ValueListenable> valueListenables;
|
||||
|
||||
/// The builder function to be called when value of any of the [ValueListenable] changes.
|
||||
/// The order of values list will be same as [valueListenables] list.
|
||||
final Widget Function(BuildContext context, List<dynamic> values, Widget? child) builder;
|
||||
|
||||
/// An optional child widget which will be available as child parameter in [builder].
|
||||
final Widget? child;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AnimatedBuilder(
|
||||
animation: Listenable.merge(valueListenables),
|
||||
builder: (context, child) {
|
||||
final providedValues = valueListenables.map((final listenable) => listenable.value);
|
||||
return builder(context, List<dynamic>.unmodifiable(providedValues), child);
|
||||
},
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
import 'package:flutter/widgets.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../abstracts/base_view_model.dart';
|
||||
import '../../abstracts/base_view_model.dart';
|
||||
|
||||
class ViewModelBuilder<T extends BaseViewModel> extends StatefulWidget {
|
||||
const ViewModelBuilder({
|
Loading…
Add table
Add a link
Reference in a new issue