Created
April 27, 2025 18:13
-
-
Save fredgrott/ba81a67767d3d5e96d4cbd7026c77532 to your computer and use it in GitHub Desktop.
current route
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Data class to hold current FlexScaffold destination route for top level and | |
// top level destination pushed on top in small device navigation. | |
import 'package:app_scaffold/flex/flex_target.dart'; | |
import 'package:flutter/foundation.dart'; | |
@immutable | |
class CurrentRoute { | |
const CurrentRoute({ | |
this.usePush = false, | |
required this.destination, | |
required this.pushedDestination, | |
// required this.navKey, | |
}); | |
/// Use push to put the destination as a route on top of other top level | |
/// navigation destinations. | |
final bool usePush; | |
/// Current top level destination | |
final FlexTarget destination; | |
/// Current top level destination, but pushed on top in mobile/small views. | |
final FlexTarget pushedDestination; | |
CurrentRoute copyWith({ | |
bool? usePush, | |
FlexTarget? destination, | |
FlexTarget? pushedDestination, | |
}) { | |
return CurrentRoute( | |
usePush: usePush ?? this.usePush, | |
destination: destination ?? this.destination, | |
pushedDestination: pushedDestination ?? this.pushedDestination, | |
); | |
} | |
@override | |
String toString() { | |
return 'AppNavigation(useModalDestination: $usePush, ' | |
'destination: $destination, modalDestination: $pushedDestination'; | |
} | |
@override | |
bool operator ==(Object other) { | |
if (identical(this, other)) return true; | |
return other is CurrentRoute && | |
other.usePush == usePush && | |
other.destination == destination && | |
other.pushedDestination == pushedDestination; | |
} | |
@override | |
int get hashCode { | |
return usePush.hashCode ^ destination.hashCode ^ pushedDestination.hashCode; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment