덕상상
덕상상

Reputation: 197

flutter What's the difference AppBarTheme "color" and "backgroundColor"?

color: Colors.transparent,

backgroundColor: Colors.transparent,

Color and background color have the same effect. What's the difference?

Upvotes: 1

Views: 378

Answers (2)

Valentin Vignal
Valentin Vignal

Reputation: 8212

There is no difference, color is a deprecated value and you should use backgroundColor.

If you look at the code of the AppBarTheme you will read:


  /// This property is deprecated, please use [backgroundColor] instead.
  ///
  /// Obsolete property that overrides the default value of
  /// [AppBar.backgroundColor] in all descendant [AppBar] widgets.
  ///
  /// See also:
  ///
  ///  * [backgroundColor], which serves this same purpose
  ///    as this property, but has a name that's consistent with
  ///    [AppBar.backgroundColor].
  ///  * [AppBar.backwardsCompatibility], which forces [AppBar] to depend
  ///    on this obsolete property.
  @Deprecated(
    'This property is no longer used, please use backgroundColor instead. '
    'This feature was deprecated after v2.4.0-0.0.pre.',
  )
  Color? get color => backgroundColor;

  /// Overrides the default value of [AppBar.backgroundColor] in all
  /// descendant [AppBar] widgets.
  ///
  /// See also:
  ///
  ///  * [foregroundColor], which overrides the default value for
  ///    [AppBar.foregroundColor] in all descendant widgets.
  final Color? backgroundColor;

You can also see the code on the Flutter repo.

Upvotes: 4

Omar Alshyokh
Omar Alshyokh

Reputation: 650

There is no difference between both of them, background value by default equals the color value. So, if you need custom app bar color on a specific page you can use the background-color

Upvotes: 0

Related Questions