1111// ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
1212//.title~
1313
14+ import 'package:df_safer_dart/_common.dart' ;
15+
1416import '/_common.dart' ;
1517
1618// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
1719
18- class RouteState <TExtra extends Object ?> {
20+ class RouteState <TExtra extends Object ?> extends Equatable {
1921 late final Uri uri;
2022 final TExtra ? extra;
2123 final bool skipCurrent;
2224 final AnimationEffect animationEffect;
2325 final TRouteConditionFn ? condition;
26+ final bool shouldPreserve;
2427
2528 Key get key => ValueKey (uri.toString ());
2629
@@ -31,6 +34,7 @@ class RouteState<TExtra extends Object?> {
3134 this .skipCurrent = true ,
3235 this .animationEffect = const NoEffect (),
3336 this .condition,
37+ this .shouldPreserve = false ,
3438 }) {
3539 final qp = {...uri.queryParameters, ...? queryParameters};
3640 this .uri = uri.replace (queryParameters: qp.isNotEmpty ? qp : null );
@@ -43,6 +47,7 @@ class RouteState<TExtra extends Object?> {
4347 this .skipCurrent = true ,
4448 this .animationEffect = const NoEffect (),
4549 this .condition,
50+ this .shouldPreserve = false ,
4651 }) {
4752 final uri0 = Uri .parse (pathAndQuery);
4853 final qp = {...uri0.queryParameters, ...? queryParameters};
@@ -55,15 +60,17 @@ class RouteState<TExtra extends Object?> {
5560 TExtra ? extra,
5661 bool ? skipCurrent,
5762 AnimationEffect ? animationEffect,
58- TRouteConditionFn ? condiiton,
63+ TRouteConditionFn ? condition,
64+ bool ? shouldPreserve,
5965 }) {
6066 return RouteState <TExtra >(
6167 uri ?? this .uri,
6268 queryParameters: queryParameters,
6369 extra: extra ?? this .extra,
6470 skipCurrent: skipCurrent ?? this .skipCurrent,
6571 animationEffect: animationEffect ?? this .animationEffect,
66- condition: condition ?? condition,
72+ condition: condition ?? this .condition,
73+ shouldPreserve: shouldPreserve ?? this .shouldPreserve,
6774 );
6875 }
6976
@@ -74,16 +81,17 @@ class RouteState<TExtra extends Object?> {
7481 bool skipCurrent = true ,
7582 bool animationEffect = true ,
7683 bool condition = true ,
84+ bool shouldPreserve = true ,
7785 }) {
7886 return RouteState <TExtra >(
7987 uri ? this .uri : Uri (),
8088 queryParameters: queryParameters ? this .uri.queryParameters : null ,
8189 extra: extra ? this .extra : null ,
8290 skipCurrent: skipCurrent ? this .skipCurrent : true ,
83- animationEffect: animationEffect
84- ? const NoEffect ()
85- : this .animationEffect,
91+ animationEffect:
92+ animationEffect ? const NoEffect () : this .animationEffect,
8693 condition: condition ? this .condition : null ,
94+ shouldPreserve: shouldPreserve ? this .shouldPreserve : false ,
8795 );
8896 }
8997
@@ -93,14 +101,5 @@ class RouteState<TExtra extends Object?> {
93101 bool matchPath (RouteState other) => uri.path == other.uri.path;
94102
95103 @override
96- bool operator == (Object other) {
97- if (identical (this , other)) return true ;
98- if (other is ! RouteState ) return false ;
99- return uri == other.uri && extra == other.extra;
100- }
101-
102- String get path => uri.path;
103-
104- @override
105- int get hashCode => (RouteState ).hashCode ^ uri.hashCode;
104+ List <Object ?> get props => [uri, extra];
106105}
0 commit comments