-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Closed
Labels
f: material designflutter/packages/flutter/material repository.flutter/packages/flutter/material repository.found in release: 1.22Found to occur in 1.22Found to occur in 1.22frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work on
Description
I could be wrong, but the issue is likely caused by showSelectedLabels having a default value set in the BottomNavigationBar's constructor, which makes the part after the ?? operator on this line unreachable (at least in debug mode, since it doesn't allow null) :
| showSelectedLabels: widget.showSelectedLabels ?? bottomTheme.showSelectedLabels, |
As a fix the default value could be moved from the constructor to the
build method (as it is done for showUnselectedLabels on the next line of the mentioned file).
Steps to Reproduce
Create a new project, update the contents of main.dart as follows, and run it
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
bottomNavigationBarTheme: BottomNavigationBarThemeData(
type: BottomNavigationBarType.fixed,
showSelectedLabels: false,
showUnselectedLabels: true,
),
),
home: MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _page = 0;
void _updatePage(int page) {
setState(() => _page = page);
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(child: Text('$_page')),
bottomNavigationBar: _buildBottomNavBar(),
);
}
Widget _buildBottomNavBar() {
return BottomNavigationBar(
onTap: _updatePage,
currentIndex: _page,
items: [
BottomNavigationBarItem(
icon: const Icon(Icons.looks_one),
label: 'Label 1',
),
BottomNavigationBarItem(
icon: const Icon(Icons.looks_two),
label: 'Label 2',
),
BottomNavigationBarItem(
icon: const Icon(Icons.looks_3),
label: 'Label 3',
),
],
);
}
}Expected results:
Selected item's text is not visible.
Actual results:
Selected item's text is visible.
Logs
[✓] Flutter (Channel master, 1.22.0-10.0.pre.380, on Microsoft Windows [Version 10.0.19041.508], locale en-US)
• Flutter version 1.22.0-10.0.pre.380 at E:\Android\flutter
• Framework revision ec40df9576 (11 hours ago), 2020-09-25 21:27:22 -0700
• Engine revision 3a73d073c8
• Dart version 2.11.0 (build 2.11.0-161.0.dev)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.0)
• Android SDK at E:\Android\sdk
• Platform android-30, build-tools 30.0.0
• ANDROID_SDK_ROOT = E:\Android\sdk
• Java binary at: E:\Android\Android-Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
• All Android licenses accepted.
[✓] Android Studio (version 4.0)
• Android Studio at E:\Android\Android-Studio
• Flutter plugin version 49.0.2
• Dart plugin version 193.7547
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
[✓] VS Code (version 1.49.1)
• VS Code at C:\Users\El\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.14.1
[✓] Connected device (2 available)
• Redmi Note 5 (mobile) • 4fcb747c • android-arm64 • Android 9 (API 28)
• Android SDK built for x86 (mobile) • emulator-5554 • android-x86 • Android 7.0 (API 24) (emulator)
• No issues found!
EdwynZN and Ldev007
Metadata
Metadata
Assignees
Labels
f: material designflutter/packages/flutter/material repository.flutter/packages/flutter/material repository.found in release: 1.22Found to occur in 1.22Found to occur in 1.22frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work on