Skip to content

Commit

Permalink
NarrowLayout: Use Text.data for item label (#136)
Browse files Browse the repository at this point in the history
  • Loading branch information
Feichtmeier committed May 24, 2022
1 parent db078fc commit 9314d64
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions lib/src/yaru_narrow_layout.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,15 @@ class _YaruNarrowLayoutState extends State<YaruNarrowLayout> {
showSelectedLabels: widget.showSelectedLabels,
showUnselectedLabels: widget.showUnselectedLabels,
items: widget.pageItems
.map((pageItem) => BottomNavigationBarItem(
icon: Icon(pageItem.iconData),
activeIcon: pageItem.selectedIconData != null
? Icon(pageItem.selectedIconData)
: Icon(pageItem.iconData),
label:
convertWidgetToString(pageItem.titleBuilder(context))))
.map(
(pageItem) => BottomNavigationBarItem(
icon: Icon(pageItem.iconData),
activeIcon: pageItem.selectedIconData != null
? Icon(pageItem.selectedIconData)
: Icon(pageItem.iconData),
label: convertWidgetToString(
pageItem.titleBuilder(context))),
)
.toList(),
currentIndex: _selectedIndex,
onTap: (index) {
Expand All @@ -81,13 +83,6 @@ class _YaruNarrowLayoutState extends State<YaruNarrowLayout> {
}

String convertWidgetToString(Widget widget) {
return widget is Text
? widget
.toString()
.replaceAll('Text(', '')
.replaceAll(')', '')
.replaceAll('"', '')
.replaceAll("'", '')
: '';
return widget is Text && widget.data != null ? widget.data! : '';
}
}

0 comments on commit 9314d64

Please sign in to comment.