isRoute<T extends Object?> function

Matcher isRoute<T extends Object?>({
  1. @Deprecated('Use `whereName` instead') String? named,
  2. Matcher? whereSettings,
  3. Matcher? whereName,
  4. Matcher? whereArguments,
  5. Matcher? whereMaintainState,
  6. Matcher? whereFullscreenDialog,
})

Returns a matcher that matches Routes.

The optional type T is the return type of the route. In most cases, this will be void, and can be omitted.

Additional matchers can be provided, such as whereSettings, whereName, whereArguments, whereMaintainState and whereFullscreenDialog.

expect(fooRoute, isRoute(whereName: equals('/home')));

verify(
  () => navigator.push(any(that: isRoute<void>(whereName: equals('/home')))),
).called(1);

Implementation

Matcher isRoute<T extends Object?>({
  @Deprecated('Use `whereName` instead') String? named,
  Matcher? whereSettings,
  Matcher? whereName,
  Matcher? whereArguments,
  Matcher? whereMaintainState,
  Matcher? whereFullscreenDialog,
}) {
  // Remove once `named` argument is removed.
  if (whereName == null && named != null) {
    // ignore: parameter_assignments
    whereName = equals(named);
  }

  assert(
    whereSettings == null || (whereName == null && whereArguments == null),
    'Cannot specify both `whereSettings` and `whereName` or `whereArguments`',
  );

  return _RouteMatcher<T>(
    whereSettings: whereSettings,
    whereName: whereName,
    whereArguments: whereArguments,
    whereMaintainState: whereMaintainState,
    whereFullscreenDialog: whereFullscreenDialog,
  );
}