Code Monkey home page Code Monkey logo

Comments (9)

daadu avatar daadu commented on May 26, 2024 2

This fix/feature has landed with v0.5.3 on pub.dev.

from backdrop.

daadu avatar daadu commented on May 26, 2024 1

If you pass animationController to BackdropScaffold, the dispose responsibility is of the outer widget. Ideally this is how it should be and therefore _shouldDisposeAnimationController flag was added.

The Ticker was created according to logs in BackdropScaffoldState.initState (package:backdrop/scaffold.dart:397:9) which is the following:

backdrop/lib/scaffold.dart

Lines 394 to 404 in 3c6da7e

// initialize _controller
_animationController = widget.animationController ??
widget.controller ??
AnimationController(
vsync: this,
duration: Duration(milliseconds: 200),
value: widget.revealBackLayerAtStart ? 0 : 1,
);
if (widget.animationController == null && widget.controller == null) {
_shouldDisposeAnimationController = true;
}

So, the _animationController is initialized inside the widget state (and not passed) in that case, _shouldDisposeAnimationController will be true and will be disposed of, when the widget disposes.

from backdrop.

WieFel avatar WieFel commented on May 26, 2024

@felixwortmann you are right.

Actually I ask myself why _shouldDisposeAnimationController is needed at all. In my opinion it could also be removed, and the dispose method changed as follows:

@override
  void dispose() {
    _animationController?.dispose();
    super.dispose();
  }

It should work as well, wouldn't it? @daadu

from backdrop.

felixwortmann avatar felixwortmann commented on May 26, 2024

@WieFel that is exactly what I meant. I already created a pr, you can just try it out.

from backdrop.

daadu avatar daadu commented on May 26, 2024

@felixwortmann "some how" the dispose is not being called, my suspect is in the BackdropScaffoldState.dispose, super.dispose is called before controller.dispose.

Simply, interchanging that should work. The dispose of BackdropScaffoldState Should be the following :

  @override
  void dispose() {
    if (_shouldDisposeAnimationController) _animationController.dispose();
   super.dispose(); // this one at last
  }

from backdrop.

daadu avatar daadu commented on May 26, 2024

@felixwortmann Can you confirm, if the above code works for you?

from backdrop.

felixwortmann avatar felixwortmann commented on May 26, 2024

@felixwortmann Can you confirm, if the above code works for you?

That works for me. super.dispose() should just be called after

if (_shouldDisposeAnimationController) _animationController.dispose();

from backdrop.

felixwortmann avatar felixwortmann commented on May 26, 2024

I just updated my PR, can you take a look at it?

from backdrop.

daadu avatar daadu commented on May 26, 2024

Fixed with #84

from backdrop.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.