Created
February 16, 2020 15:12
-
-
Save ryanlid/e4d66e9ac19a4817358606eb43da6866 to your computer and use it in GitHub Desktop.
LinearGradient 线性渐变效果
This file contains 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: "LinearGradient线性渐变效果", | |
home: LayoutDemo(), | |
), | |
); | |
} | |
class LayoutDemo extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: Text("LinearGradient线性渐变效果"), | |
), | |
body: Center( | |
child: DecoratedBox( | |
decoration: BoxDecoration( | |
// 线性渐变 | |
gradient: LinearGradient( | |
// 起始偏移量 | |
begin: FractionalOffset(0.5, 0.0), | |
// 结束偏移量 | |
end: FractionalOffset(1.0, 1.0), | |
// 渐变颜色数据集 | |
colors: <Color>[ | |
Colors.red, | |
Colors.green, | |
Colors.blue, | |
Colors.grey, | |
], | |
), | |
), | |
child: Container( | |
width: 280.0, | |
height: 280.0, | |
child: Center( | |
child: Text( | |
"LinearGradient线性渐变效果", | |
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