栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

颤振使用什么颜色系统,为什么我们使用“ const Color”而不是“ new Color”

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

颤振使用什么颜色系统,为什么我们使用“ const Color”而不是“ new Color”

从Flutter来源

class Color {  /// 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).  const Color(int value) : value = value & 0xFFFFFFFF;

const
实例被规范化。

如果您

const Color(0xFF00CCFF)
的代码中有多个实例,则只会创建一个实例。

const
实例在编译时评估。在Dart VM中,这是加载代码的时间,但是在Flutter生产中,将使用AoT编译,因此const值会带来很小的性能优势。



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/404219.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号