Was messing around with the bottomNavigationBarTheme and noticed that the label was showing on the selected item even though showSelectedLabels was set to false. Is this a bug or am I missing something?
This behavior only holds true as long as the property is declared in the ThemeData when moved to the bottomNavigationBar it behaves as expected.
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'app',
themeMode: ThemeMode.dark,
darkTheme: ThemeData(
brightness: Brightness.dark,
primarySwatch: Colors.blueGrey,
canvasColor: Color.fromRGBO(52, 58, 70, 1),
bottomNavigationBarTheme: BottomNavigationBarThemeData(
selectedIconTheme: IconThemeData(
color: Color.fromRGBO(113, 124, 152, 1),
size: 28,
),
unselectedIconTheme: IconThemeData(
color: Color.fromRGBO(196, 201, 212, 1),
size: 28,
),
type: BottomNavigationBarType.fixed,
showSelectedLabels: false,
showUnselectedLabels: false,
),
cardColor: Color.fromRGBO(52, 58, 70, 1)
),
home: HomePage(),
);
}
}
class HomePage extends StatefulWidget {
HomePage({Key key}) : super(key: key);
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
int _selectedIndex = 0;
void _onItemTapped(int index) {
setState(() {
_selectedIndex = index;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('appbar'),
),
body: Center(
child: Text('Text here'),
),
bottomNavigationBar: BottomNavigationBar(
items: const <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: Icon(Icons.access_time),
title: Text('a'),
),
BottomNavigationBarItem(
icon: Icon(Icons.view_day),
title: Text('a'),
),
BottomNavigationBarItem(
icon: Icon(Icons.equalizer),
title: Text('a'),
),
BottomNavigationBarItem(
icon: Icon(Icons.notifications_active),
title: Text('a'),
),
BottomNavigationBarItem(
icon: Icon(Icons.account_circle),
title: Text('a'),
),
],
currentIndex: _selectedIndex,
onTap: _onItemTapped,
),
);
}
}

