Flutter中的primaryColor和primarySwatch有什么区别? [英] What is the difference between primaryColor and primarySwatch in Flutter?

查看:1035
本文介绍了Flutter中的primaryColor和primarySwatch有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Flutter中,可以使用ThemeData类将主题应用于应用程序.但是,此类的两个属性使我感到困惑:primaryColorprimarySwatch.这两个属性之间的区别是什么?什么时候使用另一个属性?谢谢.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆