args<T extends BaseArguments?> static method

T? args<T extends BaseArguments?>(
  1. BuildContext context
)

Retrieves the arguments passed in when calling the navigate function.

Returned arguments are casted with the type provided, the type will always be a subtype of BaseArguments.

Make sure to provide the appropriate type, that is, provide the same type as the one passed while calling navigate, else a cast error will be thrown.

Implementation

static T? args<T extends BaseArguments?>(BuildContext context) {
  return (ModalRoute.of(context)!.settings.arguments as ArgumentsWrapper)
      .baseArguments as T?;
}