我正在尝试为我的应用程序顶部编写一个栏,并且出现一条错误消息,提示“未定义命名参数'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),
),
),
);
}
}
有人知道我为什么收到此错误吗?感谢您的帮助。
答案 0 :(得分:1)
args
属性来自decoration
,而不是Container
小部件,因此只需移动它即可。
Center