getParam<T extends RouterParam> static method

T? getParam<T extends RouterParam>(
  1. BuildContext context
)

Get the current route parameters specified using the params parameter in MomentumRouter.goto(...) method.

Example:

// setting the route params.
MomentumRouter.goto(context, DashboardPage, params: DashboardParams(...));

// accessing the route params inside widgets.
var params = MomentumRouter.getParam<DashboardParams>(context);

// accessing the route params inside controllers.
var params = getParam<DashboardParams>();

Implementation

static T? getParam<T extends RouterParam>(BuildContext context) {
  var service = Momentum.service<MomentumRouter>(context);
  var result = service.getCurrentParam<T>();
  return result;
}