Flutter-颜色
Flutter-颜色参考:Color classColor表示的是不可变的32位颜色值,ARGB格式构造方法1.Color(int value)/// Construct a color from the lower 32 bits of an [int].////// The bits are interpreted as follows://///...
Flutter-颜色
参考:
Color
表示的是不可变的32位颜色值,ARGB格式
构造方法
1.Color(int value)
/// Construct a color from the lower 32 bits of an [int].
///
/// The bits are interpreted as follows:
///
/// * Bits 24-31 are the alpha value.
/// * Bits 16-23 are the red value.
/// * Bits 8-15 are the green value.
/// * Bits 0-7 are the blue value.
///
/// In other words, if AA is the alpha value in hex, RR the red value in hex,
/// GG the green value in hex, and BB the blue value in hex, a color can be
/// expressed as `const Color(0xAARRGGBB)`.
///
/// For example, to get a fully opaque orange, you would use `const
/// Color(0xFFFF9000)` (`FF` for the alpha, `FF` for the red, `90` for the
/// green, and `00` for the blue).
@pragma('vm:entry-point')
const Color(int value) : value = value & 0xFFFFFFFF;
AA表示的是alpha值,如const Color(0xFFFF9000) FF表示的是透明度
Color c1 = const Color(0xFFFFFF); // fully transparent white (invisible) 完全透明的白色
Color c2 = const Color(0xFFFFFFFF); // fully opaque white (visible) 完全不透明的白色
2.Color.fromARGB(int a int r int g int b)
3.Color.fromRGBO(int r, int g, int b, double opacity)opacity的值在0.0和1.0之间,0.0表示完全透明,1.0表示完全不透明
Color c = const Color(0xFF42A5F5);
Color c = const Color.fromARGB(0xFF, 0x42, 0xA5, 0xF5);
Color c = const Color.fromARGB(255, 66, 165, 245);
Color c = const Color.fromRGBO(66, 165, 245, 1.0);
Colors
Flutter 内置了一套 Material Design 的颜色系统,在应用里我们可以直接使用这个颜色系统里提供的各种不同的颜色。这些颜色是在
Colors这个类里定义的一些静态属性,所以使用它们的时候一般就是用Colors这个类的名字后面加上要用的颜色的名字,比如Colors.red,Colors.yellow,Colors.blue等等。
颜色调色板
Material 颜色系统里的颜色一般还会有一组不同明暗程度的相近的颜色。这个明暗度的值一般是 50 到 900 之间,50 最亮,900 最暗。使用它们的时候可以像这样:
Colors.deepPurple[800],Colors.deepPurple[100]。
具体的可参考:
如:

Accent:强调色
你会发现有些颜色名字里面包含了一个 Accent 后缀,表示这是一种强调色,一般这些颜色更鲜艳一些。在界面上可以少量使用这种颜色来强调,突出一些东西。
更多推荐


所有评论(0)