Skip to content

Conversation

@gaspardruan
Copy link
Contributor

@gaspardruan gaspardruan commented Feb 3, 2025

Fixes #162592

Comments error:

class NavigationDestination extends StatelessWidget {
...

  /// The text label that appears below the icon of this
  /// [NavigationDestination].
  ///
  /// The accompanying [Text] widget will use
  /// [NavigationBarThemeData.labelTextStyle]. If this are null, the default
  /// text style would use [TextTheme.labelSmall] with [ColorScheme.onSurface].
  final String label;

...
}

If this are null, the default text style would use [TextTheme.labelSmall] is wrong. Actually, This is right in material2, but wrong in material3. I have dived into _NavigationBarDefaultsM3, I found this:

class _NavigationBarDefaultsM3 extends NavigationBarThemeData {
...

@override
  MaterialStateProperty<TextStyle?>? get labelTextStyle {
    return MaterialStateProperty.resolveWith((Set<MaterialState> states) {
    final TextStyle style = _textTheme.labelMedium!;
      return style.apply(
        color: states.contains(MaterialState.disabled)
          ? _colors.onSurfaceVariant.withOpacity(0.38)
          : states.contains(MaterialState.selected)
            ? _colors.onSurface
            : _colors.onSurfaceVariant
      );
    });
  }

...
}

The default text style would use [TextTheme.labelMedium] in Material3.

Changes

Just clarify the doc comments above.test-exempt

Pre-launch Checklist

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

@google-cla
Copy link

google-cla bot commented Feb 3, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. labels Feb 3, 2025
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.

@TahaTesser WDYT is this a bug or a doc issue?

@gaspardruan
Copy link
Contributor Author

gaspardruan commented Feb 6, 2025

A doc issue. Because this is already explained in class NavigationBar, but not in class NavigationDestination . It seems that someone forgot to update the corresponding doc.

class NavigationBar extends StatelssWidget {
...

  //// The text style of the label.
  ///
  /// If null, [NavigationBarThemeData.labelTextStyle] is used. If that
  /// is also null, the default text style is [TextTheme.labelMedium] with
  /// [ColorScheme.onSurface] when the destination is selected, and
  /// [ColorScheme.onSurfaceVariant] when the destination is unselected, and
  /// [ColorScheme.onSurfaceVariant] with an opacity of 0.38 when the
  /// destination is disabled.
  ///
  /// If [ThemeData.useMaterial3] is false, then the default text style is
  /// [TextTheme.labelSmall] with [ColorScheme.onSurface].
  final MaterialStateProperty<TextStyle?>? labelTextStyle;

...

}

@TahaTesser
Copy link
Member

@TahaTesser WDYT is this a bug or a doc issue?

Seems like a doc issue. Thanks for the fix! @gaspardruan.

@TahaTesser
Copy link
Member

TahaTesser commented Feb 6, 2025

@gaspardruan Additionally, please file a quick issue that this PR fixes. It's best practice, as it makes it easier to understand the proposal and track issues that are fixed.

gaspardruan and others added 2 commits February 6, 2025 17:07
Update code doc of navigation_bar.dart

Co-authored-by: Taha Tesser <[email protected]>
@gaspardruan
Copy link
Contributor Author

gaspardruan commented Feb 6, 2025

The PR fixes issue #162592.

Copy link
Member

@TahaTesser TahaTesser left a comment

Choose a reason for hiding this comment

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

LGTM!

@TahaTesser TahaTesser requested a review from bleroux February 6, 2025 10:10
Copy link
Contributor

@bleroux bleroux left a comment

Choose a reason for hiding this comment

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

LGTM!

@bleroux bleroux added the autosubmit Merge PR when tree becomes green via auto submit App label Feb 6, 2025
@auto-submit auto-submit bot added this pull request to the merge queue Feb 6, 2025
Merged via the queue into flutter:master with commit f219bba Feb 6, 2025
77 checks passed
@flutter-dashboard flutter-dashboard bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Feb 6, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 6, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 6, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 6, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 6, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 8, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 8, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 9, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 9, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 10, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 10, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 10, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 10, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 10, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 11, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 11, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 11, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 11, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 11, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 20, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 20, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 21, 2025
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

None yet

Development

Successfully merging this pull request may close these issues.

Code Comments Error in "flutter/packages/flutter/lib/src/material /navigation_bar.dart"

4 participants