gpt4 book ai didi

android - Flutter:未定义命名参数 'decoration'

转载 作者:IT王子 更新时间:2023-10-29 07:20:35 24 4
gpt4 key购买 nike

我正在尝试为我的应用程序的顶部编写一个栏,但我收到一条错误消息“未定义命名参数‘decoration’。”

import 'package:flutter/material.dart';

class GradientAppBar extends StatelessWidget {
final String title;
final double barHeight = 66.0;

GradientAppBar(this.title);

@override
Widget build(BuildContext context) {
final double statusBarHeight = MediaQuery.of(context).padding.top;

return new Container(
padding: new EdgeInsets.only(top: statusBarHeight),
height: statusBarHeight + barHeight,
child: new Center(
child: new Text(title,
style: const TextStyle(
color: Colors.white,
fontFamily: 'Poppins',
fontWeight: FontWeight.w600,
fontSize: 36.0)),
decoration: new BoxDecoration(
gradient: new LinearGradient(
colors: [const Color(0xFF3366FF), const Color(0xFF00CCFF)],
begin: const FractionalOffset(0.0, 0.0),
end: const FractionalOffset(0.5, 0.0),
stops: [0.0, 0.5],
tileMode: TileMode.clamp),
),
),
);
}
}

有谁知道我为什么会收到这个错误?感谢您的帮助。

最佳答案

decoration 属性来自 Container 而不是 Center 小部件,所以只需移动它即可。

     return new Container(
padding: new EdgeInsets.only(top: statusBarHeight),
height: statusBarHeight + barHeight,
child: new Center(
child: new Text(title,
style: const TextStyle(
color: Colors.white,
fontFamily: 'Poppins',
fontWeight: FontWeight.w600,
fontSize: 36.0)),
),

decoration: new BoxDecoration(
gradient: new LinearGradient(
colors: [const Color(0xFF3366FF), const Color(0xFF00CCFF)],
begin: const FractionalOffset(0.0, 0.0),
end: const FractionalOffset(0.5, 0.0),
stops: [0.0, 0.5],
tileMode: TileMode.clamp),
),
);

关于android - Flutter:未定义命名参数 'decoration',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55909363/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com