JaspervanRiet / duck_router

A Flutter router with intents
MIT License
4 stars 3 forks source link

feat!: use Location Type for popUntil #25

Closed DelcoigneYves closed 2 months ago

DelcoigneYves commented 2 months ago

Description

As mentioned in #24, it was a bit of a weird interface to have to instantiate a new location to use in the popUntil method (especially if this Location needed parameters). So instead, popUntil is now a generic method, where the passed type is the type of the location to pop to.

I was scratching my head a bit for checking whether the passed type was actually a subtype of Location: when forgetting to add the type, the runtime type was just Location, and so it would pop to the first Location it found. Let me know if you can think of a better solution.

Related Issues

24

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?

JaspervanRiet commented 2 months ago

Just FYI: I'm off on holiday till next week. I'll take a look then!

JaspervanRiet commented 2 months ago

My first reaction is that it would be better to have a method like this:

.popUntil((l) {
  return l is HomeLocation ? true : false;
}

thoughts?

DelcoigneYves commented 2 months ago

True, this mirrors the Navigator's popUntil more as well. I guess I was focusing too much on the type being the main filter to be added. I'll update the implementation with your suggestion!

DelcoigneYves commented 2 months ago

PR is updated 🙏