Skip to content

Instantly share code, notes, and snippets.

@ryanlid
Created Feb 16, 2020
Embed
What would you like to do?
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