我有以下文本小部件
Text(
todo.todoText!,
style: TextStyle(
fontSize: 16,
color: (isDark) ? Colors.white : Colors.black87,
decoration: todo.isDone ? TextDecoration.lineThrough : null),
decorationColor: (isDark) ? Colors.white : Colors.black87 // error
)
这是我得到的错误:
未定义命名参数“decorationColor”。尝试将名称更正为现有命名参数的名称,或定义名为“decorationColor”的命名参数
就官方文档而言 确实有一个名为
decorationColor
的命名参数。
我正在使用 Flutter 3.16.9
Flutter 3.16.9 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 41456452f2 (4 months ago) • 2024-01-25 10:06:23 -0800
Engine • revision f40e976bed
Tools • Dart 3.2.6 • DevTools 2.28.5
请帮帮我:)
是的,这是一个语法错误:
您已经关闭了 TextStyle 对象的括号,同时提供了更多参数,例如decorationColor。
decoration: todo.isDone ? TextDecoration.lineThrough : null),
装饰:todo.isDone? TextDecoration.lineThrough:空,