如何在我的flutter应用程序中添加渐变背景



我想在我的flutter应用程序的背景中使用Liner渐变色样式,如何在我的flutter应用程序中实现它?

您可以简单地在BoxDecoration中使用正确的参数

https://api.flutter.dev/flutter/painting/LinearGradient-class.html

Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topLeft,
end:
Alignment(0.8, 0.0), // 10% of the width, so there are ten blinds.
colors: [
const Color(0xffee0000),
const Color(0xffeeee00)
], // red to yellow
tileMode: TileMode.repeated, // repeats the gradient over the canvas
),
),
);

最新更新