fromValueNotifier<T> static method
Widget
fromValueNotifier<T>({
- Key? key,
- bool maintainHistory = false,
- required ValueNotifier<
T> valueNotifier, - int? getDepth(
- T value
- List<
ValueHistoryEntry< ? initialHistory,T> > - required AnimatedValueWidgetBuilder<
T> builder, - RouteTransitionsBuilder transitionsBuilder = defaultRouteTransitionsBuilder,
- Duration transitionDuration = _kDefaultTransitionDuration,
- void onPop(
- T,
- T
- bool takeFocus = false,
- bool maintainState = true,
- bool opaque = true,
- int? popPriority,
Creates an ImplicitNavigator that pushes new pages when the
valueNotifier
changes and reverts valueNotifier.value
when pages are
popped.
If non-null, getDepth
will be called on each value and used to set
ImplicitNavigator.depth. getDepth
MUST return the same depth for a
given value every time it's called on that value. If it returns
inconsistent depths, ImplicitNavigator may push redundant pages and will
not pop pages properly.
Implementation
static Widget fromValueNotifier<T>({
Key? key,
bool maintainHistory = false,
required ValueNotifier<T> valueNotifier,
int? Function(T value)? getDepth,
List<ValueHistoryEntry<T>>? initialHistory,
required AnimatedValueWidgetBuilder<T> builder,
RouteTransitionsBuilder transitionsBuilder = defaultRouteTransitionsBuilder,
Duration transitionDuration = _kDefaultTransitionDuration,
void Function(T, T)? onPop,
bool takeFocus = false,
bool maintainState = true,
bool opaque = true,
int? popPriority,
}) {
return ValueListenableBuilder<T>(
key: key,
valueListenable: valueNotifier,
builder: (context, value, child) {
return ImplicitNavigator<T>(
maintainHistory: maintainHistory,
value: valueNotifier.value,
depth: getDepth?.call(value),
initialHistory: initialHistory,
builder: builder,
transitionsBuilder: transitionsBuilder,
transitionDuration: transitionDuration,
onPop: (poppedValue, valueAfterPop) {
valueNotifier.value = valueAfterPop;
onPop?.call(poppedValue, valueAfterPop);
},
takeFocus: takeFocus,
maintainState: maintainState,
opaque: opaque,
popPriority: popPriority,
);
},
);
}