你好,我是新的扑动,我正在尝试一些东西,但我失败了,我想中心这个登录梯度文本,但我不断得到错误…目前,它默认显示在左侧。如何居中?我已经包含了小部件类和显示所有小部件的类
_loginGradientText() {
return GradientText('mySSC',
gradient: LinearGradient(colors: [
Color.fromRGBO(89, 46, 46, 0.8),
Color.fromRGBO(89, 46, 46, 0.8),
],),
style: TextStyle(fontFamily: 'Exo2',fontSize: 28, fontWeight: FontWeight.bold));
}
下面的代码显示为这个屏幕创建的所有小部件
class _LoginPageState extends State<LoginPage> {
TextEditingController _emailController = new TextEditingController();
TextEditingController _passwordController = new TextEditingController();
FocusNode _emailFocusNode = new FocusNode();
FocusNode _passFocusNode = new FocusNode();
String _email, _password;
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
Screen size;
@override
Widget build(BuildContext context) {
size = Screen(MediaQuery
.of(context)
.size);
return Scaffold(
backgroundColor: backgroundColor,
resizeToAvoidBottomInset: true,
body: AnnotatedRegion(
value: SystemUiOverlayStyle(
statusBarColor: backgroundColor,
statusBarBrightness: Brightness.light,
statusBarIconBrightness: Brightness.dark,
systemNavigationBarIconBrightness: Brightness.light,
systemNavigationBarColor: backgroundColor),
child: Container(
color: Colors.white,
child: SafeArea(
top: true,
bottom: false,
child: Stack(
fit: StackFit.expand,
children: <Widget>[
ClipPath(
clipper: BottomShapeClipper(),
child: Container(
color: colorCurve,
)),
SingleChildScrollView(
child: Container(
margin: EdgeInsets.symmetric(horizontal: size.getWidthPx(20),
vertical: size.getWidthPx(20)),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
_socialButtons1(),
_loginGradientText(),
SizedBox(height: size.getWidthPx(10)),
_textAccount(),
SizedBox(height: size.getWidthPx(30)),
loginFields()
]),
),
)
]),
),
),
));
}
如果你想从中心开始渐变,然后在所有方向上向外移动,你可以使用RadialGradient而不是LinearGradient。