Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow null YaruNavigationRailItem label with compact style #592

Merged
merged 1 commit into from
Feb 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 5 additions & 4 deletions lib/src/widgets/navi_rail/yaru_navigation_rail_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ class YaruNavigationRailItem extends StatefulWidget {
super.key,
this.selected,
required this.icon,
required this.label,
this.label,
this.tooltip,
this.onTap,
required this.style,
this.width,
});
}) : assert(style == YaruNavigationRailStyle.compact || label != null);

/// Whether the related page item is selected in the rail.
final bool? selected;
Expand All @@ -38,7 +38,8 @@ class YaruNavigationRailItem extends StatefulWidget {
final Widget icon;

/// Label widget, displayed beside the [icon].
final Widget label;
/// If [style] is [YaruNavigationRailStyle.compact], this property can be left null.
final Widget? label;

/// Optional string tooltip.
/// If not null a tooltip will be displayed on hover.
Expand Down Expand Up @@ -206,7 +207,7 @@ class _YaruNavigationRailItemState extends State<YaruNavigationRailItem> {

Widget _buildLabel(BuildContext context) {
final label = DefaultTextStyle.merge(
child: widget.label,
child: widget.label!,
style: TextStyle(
fontSize:
widget.style == YaruNavigationRailStyle.labelledExtended ? 13 : 12,
Expand Down