ValueListenableProvider<T> class
Listens to a ValueListenable
and exposes its current value.
This is useful for testing purposes, to easily simular a provider update:
test('example', () async {
// Create a ValueNotifier that tests will use to drive the application
final counter = ValueNotifier(0);
// Mount the application using ValueListenableProvider
await tester.pumpComponent(
ValueListenableProvider<int>.value(
value: counter,
child: MyApp(),
),
);
// Tests can now simulate a provider update by updating the notifier
// then calling tester.pump()
counter.value++;
await tester.pump();
});
Constructors
-
ValueListenableProvider.value({Key? key, required ValueListenable<
T> value, UpdateShouldNotify<T> ? updateShouldNotify, Component? child}) -
Listens to a
ValueListenable
and exposes its current value.
Properties
- child → Component?
-
Component which will be passed to the build.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one component replaces another component in the tree.
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
build(
BuildContext context) → Iterable< Component> - Describes the part of the user interface represented by this component.
-
createElement(
) → Element -
Creates a
StatelessElement
to manage this component's location in the tree.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited