Skip to content

Commit

Permalink
Allow null YaruNavigationRailItem label with compact style (#592)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jupi007 committed Feb 5, 2023
1 parent 123a078 commit 16746dd
Showing 1 changed file with 5 additions and 4 deletions.
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

0 comments on commit 16746dd

Please sign in to comment.