In a vanilla flutter I use to pass multiple parameters to other screen like this:
Navigator.of(context).push(MaterialPageRoute(
builder: (_) => CatalogFilterPage(
list: list,
bloc: bloc,
)))
Pretty simple and easy. I can pass 2 needed parameters, list and bloc. After use it in CatalogFilterPage.
Now after switching to go_router and looking through documentation I can't seem to find how to pass multiple data. Even passing single object seems not that good:
onTap: () =>
context.pushNamed('SelectedCatalogItem', extra: list[index]),
And in router I have to use casting to set correct type:
builder: (context, state) => SelectedCatalogItem(
item: state.extra as ListItemsModel,
),
It was fine for single parameter. But now I don't have an idea how to pass multiple parameters. How can I do it? Is even passing parameters, like models, as an extra is right way?
P.S. I know that you can pass parameters as context.pushNamed('CatalogFilterPage', params: ___)
, but params
has type of Map<String, String> witch not let me pass model's