Created
February 16, 2020 15:18
-
-
Save ryanlid/4c0fb7846394cc2191aa61ca917116b2 to your computer and use it in GitHub Desktop.
RadialGradient 环形渐变效果
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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