Coder Social home page Coder Social logo

Comments (2)

FilledStacks avatar FilledStacks commented on August 11, 2024

Thanks for filing the issue.

We will take a look at this as soon as we're back at work. It's easter break so will only be back on open source duty on Tuesday next week.

from stacked.

ferrarafer avatar ferrarafer commented on August 11, 2024

Hello @GlizzyHacker, I will try to help you. I think this is not a bug and we should, probably, deprecate createNewViewModelOnInsert.

The problem is that when you navigate back, the view and their viewmodel are pulled out of the tree, no matter if we dispose of it or not. Because of that, despite we can avoid disposing of the viewmodel, we lost the reference to it.

The solution to solve this problem is to use the locator for the ViewModel to persist the reference to it.

Steps to fix the problem:

  1. Add the following line to dependencies at @StackedApp annotation in the app.dart file.
    LazySingleton(classType: HomeViewModel),
  2. Run stacked generate command
  3. On HomeView, return HomeViewModel through the locator on viewModelBuilder like below
@override
  HomeViewModel viewModelBuilder(
    BuildContext context,
  ) => locator<HomeViewModel>();

Let me know if that doesn't work for you and I will re-open the issue.

issue-1095-demo.mp4

from stacked.

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.