1

I'm using the Flushbar plugin for Flutter.
The plugin works very well, but I can't understand how can I repeat the animation played by the animation controller that I attach to it.

AnimationController _controller;

@override
void initState() {
  _controller = AnimationController(
      vsync: this,
      duration: Duration(seconds: 3),
    );
  super.initState();
}

@override
void dispose() {
  _controller.dispose();
  super.dispose();
}

void showFlushBar() {
    Flushbar(
        titleText: Text(
          "Title",
          style: TextStyle(
              fontFamily: 'Futura',
              color: Colors.white,
              fontSize: MediaQuery.of(context).size.width / 18),
        ),
        messageText: Text(
          "Message"
          style: TextStyle(
              fontFamily: 'Futura',
              color: Colors.white,
              fontSize: MediaQuery.of(context).size.width / 25),
        ),
        showProgressIndicator: true,
        progressIndicatorBackgroundColor: Colors.blueGrey,
        progressIndicatorController: _controller,
      )..show(context);
      _controller.forward();
}

The first time the animation works well, but from the second time I get this error:

E/flutter (29680): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: 'package:flutter/src/animation/animation_controller.dart': Failed assertion: line 451 pos 7: '_ticker != null': AnimationController.forward() called after AnimationController.dispose()
E/flutter (29680): AnimationController methods should not be used after calling dispose.
E/flutter (29680): #0      _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:42:39)
E/flutter (29680): #1      _AssertionError._throwNew (dart:core-patch/errors_patch.dart:38:5)
E/flutter (29680): #2      AnimationController.forward (package:flutter/src/animation/animation_controller.dart:451:7)
E/flutter (29680): #3      _SettingsScreenState._changeLanguage (package:formula1_fan_assistant/screens/settings_screen.dart:401:19)
E/flutter (29680): #4      _asyncThenWrapperHelper.<anonymous closure> (dart:async-patch/async_patch.dart:73:64)
E/flutter (29680): #5      _rootRunUnary (dart:async/zone.dart:1134:38)
E/flutter (29680): #6      _CustomZone.runUnary (dart:async/zone.dart:1031:19)
E/flutter (29680): #7      _FutureListener.handleValue (dart:async/future_impl.dart:139:18)
E/flutter (29680): #8      Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:680:45)
E/flutter (29680): #9      Future._propagateToListeners (dart:async/future_impl.dart:709:32)
E/flutter (29680): #10     Future._completeWithValue (dart:async/future_impl.dart:524:5)
E/flutter (29680): #11     _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:32:15)
E/flutter (29680): #12     _completeOnAsyncReturn (dart:async-patch/async_patch.dart:290:13)
E/flutter (29680): #13     _SettingsScreenState.myLoadAsset (package:formula1_fan_assistant/screens/settings_screen.dart)
E/flutter (29680): #14     _asyncErrorWrapperHelper.<anonymous closure> (dart:async-patch/async_patch.dart:80:45)
E/flutter (29680): #15     _rootRunBinary (dart:async/zone.dart:1146:38)
E/flutter (29680): #16     _CustomZone.runBinary (dart:async/zone.dart:1039:19)
E/flutter (29680): #17     _FutureListener.handleError (dart:async/future_impl.dart:153:20)
E/flutter (29680): #18     Future._propagateToListeners.handleError (dart:async/future_impl.dart:692:47)
E/flutter (29680): #19     Future._propagateToListeners (dart:async/future_impl.dart:713:24)
E/flutter (29680): #20     Future._addListener.<anonymous closure> (dart:async/future_impl.dart:389:9)
E/flutter (29680): #21     _rootRun (dart:async/zone.dart:1126:13)
E/flutter (29680): #22     _CustomZone.run (dart:async/zone.dart:1023:19)
E/flutter (29680): #23     _CustomZone.runGuarded (dart:async/zone.dart:925:7)
E/flutter (29680): #24     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:965:23)
E/flutter (29680): #25     _microtaskLoop (dart:async/schedule_microtask.dart:43:21)
E/flutter (29680): #26     _startMicrotaskLoop (dart:async/schedule_microtask.dart:52:5)
E/flutter (29680): 

I really can't find a solution, neither on S.O. nor anywhere else on the Internet, so please help me.
Thanks in advance

1 Answer 1

1

I solved the issue! It was a problem with the mixin: I was using SingleTickerProviderStateMixin, when for this purpose I needed a TickerProviderStateMixin.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.