Skip to content

Commit

Permalink
Minimized the space between the icon and the title with the _ItemWidg…
Browse files Browse the repository at this point in the history
…et Class.
  • Loading branch information
Sanskar2807 committed Sep 18, 2023
1 parent a840c73 commit f7dfdc9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 19 deletions.
2 changes: 1 addition & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class _MyHomePageState extends State<MyHomePage> {
BottomNavyBarItem(
icon: Icon(Icons.message),
title: Text(
'Messages test for mes teset test test ',
'Messages',
),
activeColor: Colors.pink,
textAlign: TextAlign.center,
Expand Down
34 changes: 16 additions & 18 deletions lib/bottom_navy_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -162,23 +162,22 @@ class _ItemWidget extends StatelessWidget {
container: true,
selected: isSelected,
child: AnimatedContainer(
width: isSelected ? 130 : 50,
width: isSelected ? 130 : 50, // Limit the width here
height: double.maxFinite,
duration: animationDuration,
curve: curve,
decoration: BoxDecoration(
color:
isSelected ? item.activeColor.withOpacity(0.2) : backgroundColor,
color: isSelected ? item.activeColor.withOpacity(0.2) : backgroundColor,
borderRadius: BorderRadius.circular(itemCornerRadius),
),
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
physics: NeverScrollableScrollPhysics(),
child: Container(
width: isSelected ? 130 : 50,
width: isSelected ? 130 : 50, // Limit the width here
padding: EdgeInsets.symmetric(horizontal: 8),
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisSize: MainAxisSize.min, // Change to MainAxisSize.min to reduce space
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expand All @@ -188,24 +187,22 @@ class _ItemWidget extends StatelessWidget {
color: isSelected
? item.activeColor.withOpacity(1)
: item.inactiveColor == null
? item.activeColor
: item.inactiveColor,
? item.activeColor
: item.inactiveColor,
),
child: item.icon,
),
if (isSelected)
Expanded(
child: Container(
padding: itemPadding,
child: DefaultTextStyle.merge(
style: TextStyle(
color: item.activeColor,
fontWeight: FontWeight.bold,
),
maxLines: 1,
textAlign: item.textAlign,
child: item.title,
Container(
padding: itemPadding,
child: DefaultTextStyle.merge(
style: TextStyle(
color: item.activeColor,
fontWeight: FontWeight.bold,
),
maxLines: 1,
textAlign: item.textAlign,
child: item.title,
),
),
],
Expand All @@ -217,6 +214,7 @@ class _ItemWidget extends StatelessWidget {
}
}


/// The [BottomNavyBar.items] definition.
class BottomNavyBarItem {
BottomNavyBarItem({
Expand Down

0 comments on commit f7dfdc9

Please sign in to comment.