Skip to content

Conversation

@TahaTesser
Copy link
Member

@TahaTesser TahaTesser commented Apr 27, 2022

related #64358

minimal code sample
import 'package:flutter/material.dart';

void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {
  const MyApp({super.key, this.dark = false});

  final bool dark;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'Material App',
      theme: dark ? ThemeData.dark() : ThemeData.light(),
      home: NavigationBarSample(),
    );
  }
}

class NavigationBarSample extends StatelessWidget {
  NavigationBarSample({super.key});
  final ValueNotifier<int> _navValue = ValueNotifier<int>(0);

  static const TextStyle optionStyle =
      TextStyle(fontSize: 30, fontWeight: FontWeight.bold);
  static const List<Widget> _widgetOptions = <Widget>[
    Text(
      'Index 0: Home',
      style: optionStyle,
    ),
    Text(
      'Index 1: Business',
      style: optionStyle,
    ),
    Text(
      'Index 2: School',
      style: optionStyle,
    ),
    Text(
      'Index 3: Settings',
      style: optionStyle,
    ),
  ];

  @override
  Widget build(BuildContext context) {
    return ValueListenableBuilder<int>(
      valueListenable: _navValue,
      builder: (BuildContext context, int value, Widget? child) {
        return Scaffold(
          appBar: AppBar(
            title: const Text('BottomNavigationBar Sample'),
          ),
          body: Center(
            child: _widgetOptions.elementAt(value),
          ),
          bottomNavigationBar: BottomNavigationBar(
            selectedItemColor: Colors.red,
            unselectedItemColor: Colors.red[100],
            selectedLabelStyle: const TextStyle(
              color: Colors.green,
              // fontSize: 18.0,
            ),
            unselectedLabelStyle: TextStyle(
              color: Colors.green[100],
              // fontSize: 14.0,
            ),
            type: BottomNavigationBarType.fixed,
            items: const <BottomNavigationBarItem>[
              BottomNavigationBarItem(
                icon: Icon(Icons.home),
                label: 'Home',
              ),
              BottomNavigationBarItem(
                icon: Icon(Icons.business),
                label: 'Business',
              ),
              BottomNavigationBarItem(
                icon: Icon(Icons.school),
                label: 'School',
              ),
              BottomNavigationBarItem(
                icon: Icon(Icons.settings),
                label: 'Settings',
              ),
            ],
            currentIndex: value,
            onTap: (int newValue) {
              _navValue.value = newValue;
            },
          ),
        );
      },
    );
  }
}

BottomNavigationBar mentions the following:

If selectedLabelStyle.color and unselectedLabelStyle.color values are non-null, they will be used instead of selectedItemColor and unselectedItemColor.

but [selectedLabelStyle].color is never used by BottomNavigationBar to style label color.

            selectedItemColor: Colors.red,
            unselectedItemColor: Colors.red[100],
            selectedLabelStyle: const TextStyle(
              color: Colors.green,
              // fontSize: 18.0,
            ),
            unselectedLabelStyle: TextStyle(
              color: Colors.green[100],
              // fontSize: 14.0,
            ),

Actual Results

bug

Expected

fixed

Native reference

android_reference

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I signed the CLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@flutter-dashboard flutter-dashboard bot added f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. labels Apr 27, 2022
@TahaTesser TahaTesser requested a review from Piinks April 27, 2022 11:24
Copy link
Contributor

@Piinks Piinks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Thank you for picking this up so quickly! :)
LGTM!

@fluttergithubbot fluttergithubbot merged commit 8420246 into flutter:master Apr 27, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Apr 28, 2022
@TahaTesser TahaTesser deleted the fix_bottom_nav_label_color branch April 28, 2022 06:27
Piinks added a commit that referenced this pull request Apr 28, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Apr 28, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Apr 28, 2022
egramond pushed a commit to egramond/flutter that referenced this pull request May 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.

Projects

Status: Done (PR merged)

Development

Successfully merging this pull request may close these issues.

3 participants