Destination class
A model class representing a navigation destination in a drawer or navigation bar.
Each destination consists of:
- A label displayed next to or below the icon
- An icon shown when the destination is not selected
- A selectedIcon shown when the destination is selected
Example usage:
final destinations = [
Destination(
'Profile',
profileOutlinedIcon, // Unselected state icon
profileFilledIcon, // Selected state icon
),
Destination(
'Settings',
settingsOutlinedIcon,
settingsFilledIcon,
),
];
This class is designed to work with NavigationDrawer. The icons typically form a pair where one is the outlined version and the other is the filled version of the same icon.
Example usage with NavigationDrawer:
final destinations = [
Destination(
'Profile',
Icon(Icons.person_outline), // Outlined version for unselected state
Icon(Icons.person), // Filled version for selected state
),
Destination(
'Settings',
Icon(Icons.settings_outlined),
Icon(Icons.settings),
),
];
NavigationDrawer(
destinations: destinations.map((d) =>
NavigationDrawerDestination(
icon: d.icon,
selectedIcon: d.selectedIcon,
label: Text(d.label),
),
).toList(),
)
Common icon pairs:
- Profile: Icons.person_outline and Icons.person
- Settings: Icons.settings_outlined and Icons.settings
- Home: Icons.home_outlined and Icons.home
- Notifications: Icons.notifications_outlined and Icons.notifications
Constructors
- Destination.new(String label, Widget icon, Widget selectedIcon)
-
Creates a new navigation destination.
const
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- icon → Widget
-
The icon displayed when this destination is not selected.
final
- label → String
-
The text label displayed for this destination.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- selectedIcon → Widget
-
The icon displayed when this destination is selected.
final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited