Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Andrious Solutions
    @Andrious
    I don't particular like the solution, but what do you think? It's a subtle change---passing 'the View' within an anonymous function and passing that function as a parameter. Not particularly a pretty approach, but do you think it a suitable approach as a stable solution?
    jasonlaw
    @jasonlaw
    Hi Greg, as for me, I am fine with the approach as long as it is stable.
    I have tested the mxc_application example and it seems working fine without error now.
    Unfortunately, the example could be too simple for stability testing.
    I am still encountering error when hitting the reload.
    image.png
    jasonlaw
    @jasonlaw
    It could be either the solution is not complete, or I have misused the framework, both case are also risk to me. And I think it is near to impossible for you to help if not seeing the code. Due to this, I have convinced my manager to share the code with you, I hope you can spend some time for me to identify the problem.
    jasonlaw
    @jasonlaw
    FYI, I am using VCode. To reproduce the error, simply run the main.dart in viqcore_community, once the App is loaded (in login page), simply hit the hot reload button, the error will be thrown.
    Somehow, I am still struggling with the dispose flow....:(
    Andrious Solutions
    @Andrious
    Jason, I will look at it now, and do what I can for you.
    Andrious Solutions
    @Andrious
    With the revelation that the 'hot reload' was calling 'the View' StatefulWidget to be built again, the Flutter framework would not allow this as its associated State object already had it referenced (). Hence, you'd get the error. To resolve this, again a stable but I feel temporary approach, I made the change to 're instantiate' the View StatefulWidget all over again. That means the View can't use the factory constructor any more.
    image.png
    No real consequence. As a developer, you know not to instantiate more than one instance of this class---only, as it happens, when you perform a 'hot reload'. You'll find it'll now work without error if you make that class use only a conventional constructor.
    jasonlaw
    @jasonlaw
    Hi Greg, thank you very much for the help. Unfortunately, I am still encountering the error after making the changes. Somehow I feel (I am really not sure) it is due to the multiple calls of dispose by the framework.
    Andrious Solutions
    @Andrious
    Indeed, the latest version of your mvc_pattern 'developing' should stop multiple call to dispose
    jasonlaw
    @jasonlaw
    oh, you just made a changes? Ok I will refresh to the latest one and test again, thanks!
    Andrious Solutions
    @Andrious
    Upgrade your dependencies and see the latest version of mvc_pattern has a new variable called, _disposed.
    And yet, I didn't think that was the issue I was having.... Guess I misunderstood the issue you were having.
    jasonlaw
    @jasonlaw
    it works great now! I have been troubled by this for week, really really appreciate your help! Thank you!!!
    Andrious Solutions
    @Andrious
    Good to hear....
    jasonlaw
    @jasonlaw
    Hi Greg, there is a bug in the mxc_application, App class. Strangely, the error only occur in the released apk, running debugging mode under dev is always working fine.
    image.png
    Andrious Solutions
    @Andrious
    I shall look into it right away.
    Andrious Solutions
    @Andrious
    I did make some changes to the latest version of mxc_application to make it not fail so blatantly. However, I suspect you'll still get an error on your side. That's because I believe you're returning a 'null' from the init() function for some reason. It would be either Future<false> or Future<true>, but you'll have to 'step through that code' and determine why it is instead returning null.
    I have uploaded, the latest mxc_application package with these modifications. In the screenshot, I have red arrows where I made the changes and one on the init() function where your own code may be generating a 'null' only when in the release apk.
    image.png
    I suspect now what will happen is your app will not progress any farther once it starts up. It will constantly display the loading screen because, your code is returning 'null' in the init() function for one reason or another. That is what I suspect at this point in time.
    jasonlaw
    @jasonlaw
    Hi Greg, I have the same thought as well when I hit the error, which I have returning null from the init() function. However, I couldn't find it after I have checked the code many times. Really have no clue where the null coming from. Anyway, since this issue can be resolved easily so I would work with the solution, even it could be just a workaround.
    Btw, I have another problem with hot reload.
    I found that when hot reload the view is re-created as intended:
    image.png
    However, the initApp is not called after the recreation of view, since it is responsible in calling the AppController.init, failed to call it may give problem to the app, since most of the state value is reset after the recreation of view.
    image.png
    Do you see this a problem?
    jasonlaw
    @jasonlaw
    End up, I found the main culprit is not in initApp, but the AppView,initState is not called after re-create. It seems the sequence of AppView creation is different when in hot reload. After I added the following code in my AppViewState then I get the correct result.
    image.png
    Sorry, I mean the AppView.Init is not called
    Andrious Solutions
    @Andrious
    image.png
    This code in a controller object you wish to run with every hot reload. Possibly, you have it in the wrong controller? Without making such a change as you did above, simply place whatever code that seems to be necessary to run again with every 'reload' in the 'initState()' of the controller indicated in the screenshot.
    You see, looking at your modifications, the code in the 'init()' is obviously not 'asynchronous operations'. Anything in the 'init()' should return a type of Future<bool>, and yet you've placed in the initState() of the AppView?? I'm sorry, but that doesn't make sense to me.
    image.png
    image.png
    Andrious Solutions
    @Andrious
    image.png
    image.png
    Andrious Solutions
    @Andrious
    Above now is a sequence of screenshots conveying the 'path of execution' for a hot reload. I'm running 'an example app' called ContactsExampleApp. You can see its AppView's init() is being fired with every 'hot reload'. I don't understand the problem you're experiencing.
    jasonlaw
    @jasonlaw
    Hi Greg, thanks for looking into this issue, I have made some small change in your example to reproduce the error.
    image.png
    in _ContactListState:
    image.png