JaspervanRiet / duck_router

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

Question On Params #36

Closed rlee1990 closed 1 week ago

rlee1990 commented 1 week ago

I could not find any information on using path params or query params can you help on this?

rlee1990 commented 1 week ago

@JaspervanRiet is this supported?

JaspervanRiet commented 1 week ago

I'm sorry, but I don't understand your question. DuckRouter does not use URLs, so path/query params are not relevant to it. I recommend reading the README.

rlee1990 commented 1 week ago

@JaspervanRiet is there a way to pass data then? I read the readme but don't see any reference.

JaspervanRiet commented 1 week ago

Ah I understand your confusion, the README needs some improvement there. I have made #37 to fix it.

The short answer is, like this:

class DetailScreen extends Location {
  const DetailScreen({required this.id});

  @override
  String get path => 'detail/${id}';

  final int id;

  @override
  LocationBuilder? get builder => (c) {
        return DetailScreen(id: id);
      };
}

This is one of DuckRouter's most powerful concepts. These are just classes, so you can use any type, as many parameters as you want.

rlee1990 commented 1 week ago

Thanks @JaspervanRiet