Flutter-颜色

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.01.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.redColors.yellowColors.blue 等等。

颜色调色板

Material 颜色系统里的颜色一般还会有一组不同明暗程度的相近的颜色。这个明暗度的值一般是 50 到 900 之间,50 最亮,900 最暗。使用它们的时候可以像这样:Colors.deepPurple[800]Colors.deepPurple[100]

具体的可参考:

如:

pink

Accent:强调色

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

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值