Is your feature request related to a problem? Please describe.
When using flutter_map_animations with flutter_hooks, the AnimatedMapController requires a TickerProvider for its vsync parameter.
Currently, using the useSingleTickerProvider hook work at the first animation, but at the second animation the following error thorws:
attempted to use a useSingleTickerProvider multiple times.
A SingleTickerProviderStateMixin can only be used as a TickerProvider once.
If you need multiple Tickers, consider using useSingleTickerProvider multiple times
to create as many Tickers as needed.
In my use case, I cannot predict how many AnimationController instances will be created, so I need a useMultiTickerProvider hook to handle this dynamically.
Describe the solution you'd like
I would like a new hook, useMultiTickerProvider, that extends TickerProviderStateMixin instead of SingleTickerProviderStateMixin. This would allow the creation of multiple AnimationController instances without the limitation of a single TickerProvider. The hook should be usable like this:
AnimatedMapController useMapController(double initialZoom, Duration debounceDuration) {
final ticker = useSingleTickerProvider();
final controller = useMemoized(() => AnimatedMapController(vsync: ticker));
useEffect(() {
return () {
try {
controller.dispose();
} catch (_) {}
};
}, const []);
return controller;
}
Describe alternatives you've considered
- Using
useSingleTickerProvider multiple times: This is not feasible because the number of required AnimationController instances is dynamic and unpredictable.
Is your feature request related to a problem? Please describe.
When using
flutter_map_animationswithflutter_hooks, theAnimatedMapControllerrequires aTickerProviderfor itsvsyncparameter.Currently, using the
useSingleTickerProviderhook work at the first animation, but at the second animation the following error thorws:In my use case, I cannot predict how many
AnimationControllerinstances will be created, so I need auseMultiTickerProviderhook to handle this dynamically.Describe the solution you'd like
I would like a new hook,
useMultiTickerProvider, that extendsTickerProviderStateMixininstead ofSingleTickerProviderStateMixin. This would allow the creation of multipleAnimationControllerinstances without the limitation of a singleTickerProvider. The hook should be usable like this:Describe alternatives you've considered
useSingleTickerProvidermultiple times: This is not feasible because the number of requiredAnimationControllerinstances is dynamic and unpredictable.