Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FlareActor holds incorrect callback references #284

Closed
ghost opened this issue Oct 25, 2020 · 1 comment
Closed

FlareActor holds incorrect callback references #284

ghost opened this issue Oct 25, 2020 · 1 comment

Comments

@ghost
Copy link

ghost commented Oct 25, 2020

Within my app, I'm calling the same FlareActor twice (through a private stateless widget) but with different callback functions. The first callback calls a null (it loops a loading animation so it's not going use the callback either way) and the second time it's a function that notifies that the 'done' animation is complete.

I've modified my code to provide some helpful print statements (including changing the parent).

Stateless Widget (with FlareActor)
class _Splash extends StatelessWidget {
  const _Splash({Key key, this.isLoading = true, this.onComplete})
      : super(key: key);

  final bool isLoading;
  final Function onComplete;

  @override
  Widget build(BuildContext context) {
    print('Flutter: $onComplete');

    return Center(
      child: SizedBox(
        height: 250,
        child: FlareActor(
          "lib/graphics/splash-screen.flr",
          alignment: const Alignment(0, 0),
          fit: BoxFit.contain,
          animation: isLoading ? 'loading' : 'done',
          callback: (_) {
            print('FlareActor: $onComplete');
          },
        ),
      ),
    );
  }
}
Parent Widget (Important bits only)
if (state is SplashScreenLoading) {
  return _Splash(onComplete: () => 'stringType');
}

if (state is SplashScreenSuccess) {
  return _Splash(isLoading: false, onComplete: () => cubit.animationEnded());
}

So I expect the FlareActor to call the new function, but that's not what happens.

Print Statements
I/flutter ( 3231): Flutter: Closure: () => String
I/flutter ( 3231): Flutter: Closure: () => void
I/flutter ( 3231): FlareActor: Closure: () => String

Notice how flutter (and thus the widget) has the reference to the new function (which goes to void) but FlareActor is calling the old function? Am I doing something wrong or is this not intended?

@ghost
Copy link
Author

ghost commented Oct 26, 2020

Duplicate of #276

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants