Skip to content

Instantly share code, notes, and snippets.

@ryanlid
Created February 16, 2020 15:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanlid/4c0fb7846394cc2191aa61ca917116b2 to your computer and use it in GitHub Desktop.
Save ryanlid/4c0fb7846394cc2191aa61ca917116b2 to your computer and use it in GitHub Desktop.
RadialGradient 环形渐变效果
import 'package:flutter/material.dart';
void main() {
runApp(
MaterialApp(
title: "RadizlGradient 环形渐变效果",
home: LayoutDemo(),
),
);
}
class LayoutDemo extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("RadizlGradient 环形渐变效果"),
),
body: Center(
child: DecoratedBox(
decoration: BoxDecoration(
// 环形渐变
gradient: RadialGradient(
// 中心点偏移量,x,y为0 表示在正中心位置
center: Alignment(-0.0, -0.0),
// 圆形半径
radius: 0.5,
// 渐变颜色数据集
colors: <Color>[
Colors.green,
Colors.blue,
Colors.grey,
],
),
),
child: Container(
width: 280.0,
height: 280.0,
child: Center(
child: Text(
'RadialGradient 环形渐变效果',
style: TextStyle(
color: Colors.black,
fontSize: 28.0,
),
),
),
),
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment