どうも、ちょげ(@chogetarou)です。
色をグラデーションにする方法を紹介します。
方法

色をグラデーションにするには、Containerを使います。
まず、Containerの引数「decoration」にBoxDecorationを指定します。
そして、BoxDecoraitonの引数にGradientのクラスを指定します。
Container(
decoration: BoxDecoration(
gradient: LinearGradient(・・・),
),
),
BoxDecorationの引数「gradient」にGradientのクラスを指定することで、色をグラデーションにできます。
使用例

@override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
body: Center(
child: Container(
height: 200,
width: 200,
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [Colors.blue, Colors.yellow],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
),
),
),
),
);
}
コメント