Rodrigo Lopez Peker

New Ticker Mixin for AnimationController.

- Added SingleGetTickerProviderMixin to rx_interface.dart, usage like SingleTickerProviderMixin in a StatefulWidget, but only valid for DisposableInterfaces.
@@ -72,3 +72,25 @@ abstract class DisposableInterface { @@ -72,3 +72,25 @@ abstract class DisposableInterface {
72 /// Might be useful as well to persist some data on disk. 72 /// Might be useful as well to persist some data on disk.
73 void onClose() async {} 73 void onClose() async {}
74 } 74 }
  75 +
  76 +/// Used like [SingleTickerProviderMixin] but only with Get Controllers.
  77 +/// Simplifies AnimationController creation inside GetxController.
  78 +///
  79 +/// Example:
  80 +///```
  81 +///class SplashController extends GetxController with SingleGetTickerProviderMixin {
  82 +/// AnimationController _ac;
  83 +///
  84 +/// @override
  85 +/// void onInit() {
  86 +/// final dur = const Duration(seconds: 2);
  87 +/// _ac = AnimationController.unbounded(duration: dur, vsync: this);
  88 +/// _ac.repeat();
  89 +/// _ac.addListener(() => print("Animation Controller value: ${_ac.value}"));
  90 +/// }
  91 +/// ...
  92 +/// ```
  93 +mixin SingleGetTickerProviderMixin on DisposableInterface
  94 + implements TickerProvider {
  95 + Ticker createTicker(TickerCallback onTick) => Ticker(onTick);
  96 +}