【发布时间】:2020-07-03 20:16:02
【问题描述】:
我最近在尝试使用渐变创建跟随 AppBar 时遇到了一个问题。
当我尝试用色彩来复制这个设计时 玫瑰=颜色(0xFFec15ee), 紫色 = 颜色(0xFF8561f5)和 blue = Color(0xFF1eaefc) 并相应地设置对齐属性,它以某种方式给了我没有预期的结果
BoxDecoration(
gradient: LinearGradient(
colors: [
AppColors.roseGradientColor,
AppColors.purpleInAppGradientColor,
AppColors.blueInAppGradientColor
],
stops: [
0.0,
0.05,
1.0
],
begin: Alignment.bottomLeft,
end: Alignment.topRight
),
borderRadius: BorderRadius.only(bottomLeft: Radius.circular(25),bottomRight: Radius.circular(25))
)
想象一下不透明度不会存在。如您所见,我只希望玫瑰在 bottomLeft 对齐,而不是向上扩展至 topLeft,如示例所示。
我的问题是我该怎么做。在 CustomPainter 中必须有一种方法可以做到这一点,但我还没有找到正确的方法。
【问题讨论】:
-
代替
Alignment.topRight使用远远高于top的Alignment- 请参阅Alignment(double, double)构造函数
标签: user-interface flutter dart gradient custom-painting