GithubHelp home page GithubHelp logo

Comments (8)

Milad-Akarie avatar Milad-Akarie commented on May 22, 2024 1

@skybur finally fixed in auto_route_generator 0.4.10 Thanks @nateshmbhat

from auto_route_library.

Milad-Akarie avatar Milad-Akarie commented on May 22, 2024

@skybur I'll look into it. Are you sure it's a good idea to pass a callback func to a route though?

from auto_route_library.

skybur avatar skybur commented on May 22, 2024

Well, one of my use case is like this

  • I have Screen A with list of items loaded from network and cached.
  • I click an item to navigate to Screen B which is the item detail screen.
  • There I can update the item properties without popping the detail screen
  • I want to refresh the Screen A's item list (some of the properties are displayed there) so I provided the callback to Screen B to call when the item changed

I can't think any other way besides providing callback.

from auto_route_library.

Milad-Akarie avatar Milad-Akarie commented on May 22, 2024

@skybur You could have a shared model/bloc between your master/details screens or if you're going for a simpler approach you could have your DetailsScreenRoute return the edited ITEM then update your list from there

var editedItem = await Router.navigator.push(Router.detailsScreen);
// inside of your details screen pop with Results
  Router.navigator.pop([editedItem]);

from auto_route_library.

skybur avatar skybur commented on May 22, 2024

I tried using Navigator.pop to pass back value, but I don't quite like it, because I think it's not descriptive enough about what will be returned. I mean I need to see inside the class that calls Navigator.pop to know what will be returned. On the other hand if I used callback to return the value, I know what will be returned. That's just me though and maybe that's not a good practice.

However I'm gonna try your suggestion since I'm totally gonna use this package for routing, thanks!

from auto_route_library.

Milad-Akarie avatar Milad-Akarie commented on May 22, 2024

@skybur, You can easily type your returned results

@MaterialRoute(returnType: ITEMTYPE)
DetailsScreen detialsScreen;
....

Router.navigator.pushNamed<ITEMTYPE>()
Router.navigator.pop<ITEMTYPE>(item)

I hope this helps. and thanks for reporting the bug, I'll let you know when it's fixed.

from auto_route_library.

skybur avatar skybur commented on May 22, 2024

I'm wondering what that returnType is used for. So that's how I use it!
I think that improves the descriptiveness when using Navigator.pop since I can just see in the router class what will be returned. Thanks again!

from auto_route_library.

Milad-Akarie avatar Milad-Akarie commented on May 22, 2024

@skybur You're welcome.

from auto_route_library.

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.