Skip to content

Update code comments for navigation_bar.dart - #162596

Merged
auto-submit[bot] merged 3 commits into
flutter:masterfrom
gaspardruan:master
Feb 6, 2025
Merged

auto-submit[bot] merged 3 commits into
flutter:masterfrom
gaspardruan:master

Conversation

@gaspardruan

@gaspardruan gaspardruan commented Feb 3, 2025 •

Copy link
Copy Markdown
Contributor

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

google-cla Bot commented Feb 3, 2025

Copy link
Copy Markdown

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. p: material_ui material_ui package in flutter/packages labels Feb 3, 2025

@Piinks Piinks left a comment

Copy link
Copy Markdown
Contributor

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

gaspardruan commented Feb 6, 2025 •

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
Contributor

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

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

Comment thread packages/flutter/lib/src/material/navigation_bar.dart Outdated
Comment thread packages/flutter/lib/src/material/navigation_bar.dart Outdated
@TahaTesser

TahaTesser commented Feb 6, 2025 •

Copy link
Copy Markdown
Contributor

@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

gaspardruan commented Feb 6, 2025 •

Copy link
Copy Markdown
Contributor Author

The PR fixes issue #162592.

@TahaTesser TahaTesser left a comment

Copy link
Copy Markdown
Contributor

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

@bleroux bleroux left a comment

Copy link
Copy Markdown
Contributor

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
@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

framework flutter/packages/flutter repository. See also f: labels. p: material_ui material_ui package in flutter/packages

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