copyWith method

AutoRoute copyWith({
  1. RouteType? type,
  2. String? name,
  3. String? path,
  4. bool? usesPathAsKey,
  5. List<AutoRouteGuard>? guards,
  6. bool? fullMatch,
  7. Map<String, dynamic>? meta,
  8. bool? maintainState,
  9. bool? fullscreenDialog,
  10. List<AutoRoute>? children,
  11. TitleBuilder? title,
  12. RestorationIdBuilder? restorationId,
  13. bool? keepHistory,
  14. bool? initial,
  15. bool? allowSnapshotting,
})

A simplified copyWith

Returns a new AutoRoute instance with the provided details overriding.

Implementation

AutoRoute copyWith({
  RouteType? type,
  String? name,
  String? path,
  bool? usesPathAsKey,
  List<AutoRouteGuard>? guards,
  bool? fullMatch,
  Map<String, dynamic>? meta,
  bool? maintainState,
  bool? fullscreenDialog,
  List<AutoRoute>? children,
  TitleBuilder? title,
  RestorationIdBuilder? restorationId,
  bool? keepHistory,
  bool? initial,
  bool? allowSnapshotting,
}) {
  return AutoRoute._change(
    type: type ?? this.type,
    name: name ?? this.name,
    path: path ?? this.path,
    usesPathAsKey: usesPathAsKey ?? this.usesPathAsKey,
    guards: guards ?? List.from(this.guards),
    //copy
    fullMatch: fullMatch ?? this.fullMatch,
    meta: meta ?? this.meta,
    maintainState: maintainState ?? this.maintainState,
    fullscreenDialog: fullscreenDialog ?? this.fullscreenDialog,
    children: children != null
        ? (children.isEmpty ? null : RouteCollection.fromList(children))
        : this.children,
    //copy
    title: title ?? this.title,
    restorationId: restorationId ?? this.restorationId,
    keepHistory: keepHistory ?? this.keepHistory,
    initial: initial ?? this.initial,
    allowSnapshotting: allowSnapshotting ?? this.allowSnapshotting,
  );
}