What is the difference between primaryColor and primarySwatch in Flutter?

后端 未结 2 1713
有刺的猬
有刺的猬 2020-12-05 01:39

In Flutter, one can apply a theme to the app using ThemeData class. But there two propeties of this class that confuses me: primaryColor and primarySwatch

2条回答
  •  悲&欢浪女
    2020-12-05 02:14

    primarySwatch is not a Color. It's MaterialColor. Which means it's a the different shades of a color a material app will use.

    primaryColor is one of those shades. To be exact, primaryColor is normally equal to primarySwatch[500].

    It is usually better to define a primarySwatch instead of primaryColor. Because some material components may use a different shade of the primaryColor for things such as shadow, border, ...

提交回复
热议问题