Flutter中无法设置文字装饰颜色问题求助
问题解决:未定义命名参数'decorationColor'
你的代码存在语法括号错误,decorationColor被误放在了TextStyle构造函数的外部,变成了Text组件的参数,而Text组件并没有这个命名参数,因此触发错误。
修正后的代码如下:
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, // 现在属于TextStyle的参数 ), )
Flutter 3.16.9版本的TextStyle确实支持decorationColor参数,问题核心是你在decoration参数后提前闭合了TextStyle的花括号,导致后续参数归属错误。
内容的提问来源于stack exchange,提问作者Saptarshi Dey
相关产品推荐
相关产品推荐

