Skip to content

AppBar color does not use Theme.colorScheme.primary, or docs are wrong #126168

@Piinks

Description

@Piinks

From https://twitter.com/cfdevelop/status/1654267064071380995?s=51&t=8nbBOjm4Aq2ePrI4j-37hA

According to the docs:

The default app bar backgroundColor is the overall theme's ColorScheme.primary if the overall theme's brightness is Brightness.light

But that does not appear to happen in this case:

import 'package:flutter/material.dart';

void main() => runApp(
      MaterialApp(
        theme: ThemeData(
          brightness: Brightness.light,
          useMaterial3: true,
          colorScheme: ColorScheme.fromSwatch(
            primarySwatch: Colors.blue,
          ).copyWith(
            primary: Colors.pink,
          ),
        ),
        debugShowCheckedModeBanner: false,
        home: Scaffold(
          appBar: AppBar(),
          body: const SizedBox.shrink(),
        ),
      ),
    );

Instead of a pink app bar, it is white.

I am not sure if this is a bug, or if the docs are incorrect.

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: fidelityMatching the OEM platforms bettera: qualityA truly polished experienced: api docsIssues with https://api.flutter.dev/f: material designflutter/packages/flutter/material repository.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions