Today I came over following snippet of code that implements gradient in flutter
return new Container(
...
decoration: new BoxDecoration(
gradient: new LinearGradient(
colors: [
const Color(0xFF3366FF),
const Color(0xFF00CCFF),
]
begin: const FractionalOffset(0.0, 0.0),
end: const FractionalOffset(1.0, 0.0),
stops: [0.0, 1.0],
tileMode: TileMode.clamp
),
),
),
And it raised 2 questions:
1) What color system is 0xFF3366FF
this? it looks somewhat similar to HEX, but it isn't.
2) Why do we use const
for const Color()
opposed to new Color()
I understand different between both, but const here feels unintuitive for me, I'd expect it to be creating a new Color()
class instance, similarly to how we use new Text("Some text")
. If it needs to be const, why isn't TileMode.clamp
also a const?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…