Skip to content

NavigationBar only allows labelTextStyle from NavigationBarTheme  #158508

Closed

Description

@TahaTesser

Steps to reproduce

Currently NavigationBar label text style can only be customized through NavigationBarTheme

Expected results

Can customize from NavigationBar (widget-level)

Actual results

Cannot customize on the widget level

Code sample

Code sample
import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    const TextStyle selectedTextStyle =
        TextStyle(fontSize: 15, color: Color(0xFF00FF00));
    const TextStyle unselectedTextStyle =
        TextStyle(fontSize: 15, color: Color(0xFF0000FF));
    const TextStyle disabledTextStyle =
        TextStyle(fontSize: 16, color: Color(0xFFFF0000));

    return MaterialApp(
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
          navigationBarTheme: NavigationBarThemeData(
        labelTextStyle: WidgetStatePropertyAll(
          TextStyle(
            fontSize: 14,
            fontWeight: FontWeight.bold,
            color: Theme.of(context).colorScheme.primary,
          ),
        ),
      )),
      home: Scaffold(
        appBar: AppBar(
          title: const Text('NavigationBar Sample'),
        ),
        bottomNavigationBar: NavigationBar(
          labelTextStyle: const WidgetStateProperty<TextStyle?>.fromMap(
            <WidgetStatesConstraint, TextStyle?>{
              WidgetState.disabled: disabledTextStyle,
              WidgetState.selected: selectedTextStyle,
              WidgetState.any: unselectedTextStyle,
            },
          ),
          onDestinationSelected: null,
          destinations: const <Widget>[
            NavigationDestination(
              icon: Icon(Icons.home),
              label: 'Home',
            ),
            NavigationDestination(
              icon: Icon(Icons.favorite_rounded),
              label: 'Favorites',
            ),
            NavigationDestination(
              enabled: false,
              icon: Icon(Icons.settings),
              label: 'Settings',
            ),
          ],
        ),
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[Paste your output here]

Activity

  1. added
    in triagePresently being triaged by the triage team
    frameworkflutter/packages/flutter repository. See also f: labels.
    p: material_uimaterial_ui package in flutter/packages
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    team-designOwned by Design Languages team
    and removed
    in triagePresently being triaged by the triage team
    on Nov 12, 2024
  2. self-assigned this
    on Nov 12, 2024
  3. moved this from To do to In progress in Nevercodeon Nov 12, 2024
  4. moved this from In progress to PR submitted in Nevercodeon Nov 12, 2024
  5. moved this from PR submitted to Done (PR merged) in Nevercodeon Nov 12, 2024
  6. added
    r: fixedIssue is closed as already fixed in a newer version
    on Nov 12, 2024
  7. github-actions commented on Nov 26, 2024

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  8. locked as resolved and limited conversation to collaborators on Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

found in release: 3.27Found to occur in 3.27frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: material_uimaterial_ui package in flutter/packagesr: fixedIssue is closed as already fixed in a newer versionteam-designOwned by Design Languages team

Type

No type

Projects

  • Status
    Done (PR merged)

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions