【发布时间】:2021-05-19 17:11:33
【问题描述】:
当我将 const 用于渐变颜色时,出现参数格式错误。
Expanded(
child: OpenContainer(
closedElevation: 0,
transitionType: ContainerTransitionType.fade,
transitionDuration: const Duration(milliseconds: 1000),
closedColor: const Color(0xFFE9E9E9),
openBuilder: (context, _) {
return WorkoutScreen();
},
closedBuilder: (context, VoidCallback openContainer) {
return GestureDetector(
onTap: openContainer,
child: Container(
margin: const EdgeInsets.only(bottom: 10, left: 32, right: 32),
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(30)),
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
**colors: [
const Color(0xFF20008B),
const Color(0xFF200087),
],**
),
),
这是一条错误消息:未定义命名参数“颜色”。 尝试将名称更正为现有命名参数的名称,或使用名称“colors”定义命名参数。
【问题讨论】:
-
除了
**,这是否是您的确切代码(即,您复制并粘贴它而没有进行任何其他更改)?您确定错误是指指示的行吗?你用的是什么版本的 Flutter? -
是的,“颜色”这个词给了我错误。 [√] Flutter (Channel stable, 1.22.6, on Microsoft Windows [Version 10.0.18363.1379], locale tr-TR) [√] Android toolchain - development for Android devices (Android SDK version 30.0.2
-
我用显示错误的图片编辑了我的问题。你能检查一下吗
-
是的,这个问题在我写完所有内容后就消失了。非常感谢。 @Vineet
标签: flutter dart constructor