routemaster icon indicating copy to clipboard operation
routemaster copied to clipboard

Make it easier to change part of current path

Open tomgilder opened this issue 4 years ago • 3 comments

It would be nice if it's easier to alter the current path, such as changing one query parameter.

For instance if the user is on /search?q=blah&order=popular and we want to change to /products?q=blah&order=recent, currently you have to change the entire URL:

Routemaster.of(context).push('/search', queryParameters: {'order': 'recent', 'q': query});

We could make currentRoute writeable and add a copyWith:

final routemaster = Routemaster.of(context);
routemaster.currentRoute = routemaster.currentRoute.copyWith(
  queryParameters: {
    'order': 'recent',
    'q': query
  }
);

We could make .push() nullable (but I really don't like this):

Routemaster.of(context).push(null, queryParameters: {'order': 'recent', 'q': query});

...or there could be an entire new method.

But it would be nice if somehow you could just update one parameter, not have to create a new map with all of them.

tomgilder avatar May 27 '21 14:05 tomgilder

There could also be Routemaster.of(context).updateRoute((route) => route.copyWith(...))

tomgilder avatar May 28 '21 05:05 tomgilder

Or adding a pushRoute method: Routemaster.of(context).pushRoute(RouteData.of(context).copyWith(...))

tomgilder avatar Jun 06 '21 08:06 tomgilder

or Routemaster.of(context).updateRoute(queryParameters: {'order': 'recent', 'q': query}); ?

because I think push is unclear.

rnl-veolys avatar Jun 21 '21 11:06 rnl-veolys