Flutter中的primaryColor和primarySwatch有什么区别? [英] What is the difference between primaryColor and primarySwatch in Flutter?
问题描述
在Flutter中,可以使用ThemeData类将主题应用于应用程序.但是,此类的两个属性使我感到困惑:primaryColor
和primarySwatch
.这两个属性之间的区别是什么?什么时候使用另一个属性?谢谢.
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
. What's the difference between these two properties and when to use one or the other? Thanks.
推荐答案
primarySwatch
不是 一个Color
. MaterialColor
.
这意味着材料应用将使用不同的颜色深浅.
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
是这些阴影之一.确切地说,primaryColor
通常等于primarySwatch[500]
.
primaryColor
is one of those shades. To be exact, primaryColor
is normally equal to primarySwatch[500]
.
通常最好定义一个primarySwatch
而不是primaryColor
.因为某些材质组件可能对阴影,边框,...
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, ...
这篇关于Flutter中的primaryColor和primarySwatch有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!