Skip to content

BottomAppBar: surfaceTintColor doc wrongly says "If this is null, no overlay will be applied." #124535

@chrisbobbe

Description

@chrisbobbe

Here's the full doc on BottomAppBar.surfaceTintColor currently:

  /// The color used as an overlay on [color] to indicate elevation.
  ///
  /// If this is null, no overlay will be applied. Otherwise the
  /// color will be composited on top of [color] with an opacity related
  /// to [elevation] and used to paint the background of the [BottomAppBar].
  ///
  /// The default is null.
  ///
  /// See [Material.surfaceTintColor] for more details on how this overlay is applied.
  final Color? surfaceTintColor;

But when surfaceTintColor is null, an overlay is applied. In this code sample, compare a Container with a BottomAppBar that are both given the same gray for their color param:

import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

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

  @override
  Widget build(BuildContext context) {
    Color color = const Color.fromRGBO(90, 90, 90, 1);
    return MaterialApp(
      theme: Theme.of(context).copyWith(useMaterial3: true),
      home: Scaffold(
        body: Align(alignment: Alignment.bottomCenter, child: Container(width: 100, height: 100, color: color)),
        bottomNavigationBar: BottomAppBar(
          color: color,
          child: Row(children: [IconButton(onPressed: () {}, icon: const Icon(Icons.menu))])
        ),
      ),
    );
  }
}

The bottom app bar gets its bluish tint from a default surface tint color, which I think in this case is ColorScheme.primary:

Color get surfaceTint => _surfaceTint ?? primary;

Probably the behavior is right, and the doc should be updated to say something like:

  /// A custom color for the Material 3 surface-tint elevation effect.
  ///
  /// In Material 3, a "surface tint" with an opacity related to [elevation]
  /// will be applied to the [BottomAppBar]'s background.
  /// Use this property to override the default color of that tint.
  ///
  /// If this property is null, then [BottomAppBarTheme.surfaceTintColor]
  /// of [ThemeData.bottomAppBarTheme] is used.
  /// If that is also null, [ColorScheme.surfaceTint] is used.
  ///
  /// Ignored if [ThemeData.useMaterial3] is false.
  ///
  /// The default is null.
  ///
  /// See [Material.surfaceTintColor] for more details on how this overlay is applied.
  final Color? surfaceTintColor;

Metadata

Metadata

Assignees

No one assigned

    Labels

    d: api docsIssues with https://api.flutter.dev/f: material designflutter/packages/flutter/material repository.frameworkflutter/packages/flutter repository. See also f: labels.r: fixedIssue is closed as already fixed in a newer version

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions