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

Time:03-15

color: Colors.transparent,

backgroundColor: Colors.transparent,

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

CodePudding user response:

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 this the code on the Flutter repo.

CodePudding user response:

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

  • Related