我在Android上有这个渐变:
<gradient
android:angle="45.0"
android:centerColor="#ffeeeeee"
android:endColor="#ffbbbbbb"
android:startColor="#ffcccccc" />
我希望它能在抖动时复制它,但我无法这样做。 我曾经尝试使用LinearGradient,但甚至没有达到Android上的水平。
我尝试过:
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
gradient: LinearGradient(
colors: [
Color(0xffeeeeee),
Color(0xffcccccc),
Color(0xffbbbbbb),
],
begin: Alignment(-1.0, -4.0),
end: Alignment(1.0, 4.0),
),
),
谢谢
答案 0 :(得分:0)
您可以这样做
return Scaffold(
body: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [Colors.red, Colors.orange],
begin: Alignment.topLeft,
end: Alignment.bottomRight)),
child: Container(
)),
);
对于颜色代码,请这样做
Color hexToColor(String code) {
return new Color(int.parse(code.substring(1, 7), radix: 16) + 0xFF000000);
}
答案 1 :(得分:0)
尝试将渐变添加为:
Container(height: 200,
width: 350,
decoration: BoxDecoration(
color: Colors.white,
gradient: LinearGradient(
begin: FractionalOffset.topCenter,
end: FractionalOffset.bottomCenter,
colors: [
Color.fromRGBO(0, 0, 0, 0.0),
Color.fromRGBO(0, 0, 0, 0.25),
Color.fromRGBO(0, 0, 0, 0.7),
],
stops: [0.5, 0.7, 0.9],
)),
),