# AppBar theme color parameter deprecation

> The color parameter in AppBarTheme and AppBarThemeData has been deprecated in favor of backgroundColor for better API consistency.




:::important
These breaking change docs are accurate, as of the release
under which they are published. Over time, the
workarounds described here might become inaccurate.
We don't, in general, keep these breaking change docs up
to date as of each release.

这些破坏性改动文档的准确性仅限于其发布时对应的版本。
随着时间的推移，文档中描述的方案可能会逐渐失效。
通常情况下，我们不会在每次发布新版本时都对这些文档进行同步更新。

The [breaking change index file](/release/breaking-changes)
lists the docs created for each release.

[破坏性改动列表](/release/breaking-changes) 
列出了每个版本的文档。

:::


## Summary

The `color` parameter in `AppBarTheme` and `AppBarThemeData` constructors
and their `copyWith` methods have been deprecated. Use `backgroundColor`
instead. This change affects how AppBar themes are configured and might
cause deprecation warnings in existing code.

## Background

The AppBar theming system had two parameters that controlled the same
property: `color` and `backgroundColor`. This duplication created confusion
and inconsistency in the API. To improve clarity and consistency, the
`color` parameter has been deprecated in favor of `backgroundColor`.

The deprecation affects the following classes and methods:

- `AppBarTheme` constructor
- `AppBarTheme.copyWith` method
- `AppBarThemeData` constructor
- `AppBarThemeData.copyWith` method

When using the deprecated `color` parameter, you'll see warnings like:

```txt
'color' is deprecated and shouldn't be used. Use backgroundColor instead.
This feature was deprecated after v3.33.0-0.2.pre.
```

The classes also include assertion checks to prevent using both parameters
simultaneously:

```txt
The color and backgroundColor parameters mean the same thing. Only specify one.
```

## Migration guide

Replace all uses of the `color` parameter with `backgroundColor` in
`AppBarTheme` and `AppBarThemeData` constructors and `copyWith` methods.

Code before migration:

```dart
// AppBarTheme constructor
AppBarTheme(
  color: Colors.blue,
  elevation: 4.0,
)

// AppBarTheme copyWith
theme.copyWith(
  color: Colors.red,
  elevation: 2.0,
)

// AppBarThemeData constructor
AppBarThemeData(
  color: Colors.green,
  elevation: 4.0,
)

// AppBarThemeData copyWith
themeData.copyWith(
  color: Colors.purple,
  elevation: 2.0,
)
```

Code after migration:

```dart
// AppBarTheme constructor
AppBarTheme(
  backgroundColor: Colors.blue,
  elevation: 4.0,
)

// AppBarTheme copyWith
theme.copyWith(
  backgroundColor: Colors.red,
  elevation: 2.0,
)

// AppBarThemeData constructor
AppBarThemeData(
  backgroundColor: Colors.green,
  elevation: 4.0,
)

// AppBarThemeData copyWith
themeData.copyWith(
  backgroundColor: Colors.purple,
  elevation: 2.0,
)
```

## Timeline

Landed in version: 3.33.0-0.2.pre<br>
In stable release: 3.35.4

## References

API documentation:

- [`AppBarTheme`](https://main-api.flutter.dev/flutter/material/AppBarTheme-class.html)
- [`AppBarThemeData`](https://main-api.flutter.dev/flutter/material/AppBarThemeData-class.html)

Relevant PRs:

- [AppBar theme color parameter deprecation #170624](https://github.com/flutter/flutter/pull/170624)

