gpt4 book ai didi

flutter - 无法将参数类型 'List'分配给参数类型 'MaterialColor'

转载 作者:行者123 更新时间:2023-12-03 02:50:15 26 4
gpt4 key购买 nike

为什么不能将accents设置为颜色?
这是我的代码:

Text('Hello',
style: TextStyle(color: Colors.accents),
)

最佳答案

实际上,口音不是color,而是包含许多list(口音颜色)的colors(常量List口音)。
它的实现是:

static const List<MaterialAccentColor> accents = <MaterialAccentColor>[
redAccent,
pinkAccent,
purpleAccent,
deepPurpleAccent,
indigoAccent,
blueAccent,
lightBlueAccent,
cyanAccent,
tealAccent,
greenAccent,
lightGreenAccent,
limeAccent,
yellowAccent,
amberAccent,
orangeAccent,
deepOrangeAccent,
]
您可以通过 link在flutter网站上找到它
现在我们知道它是 list,要检索其元素之一,只需执行 List_name[element_index]即可。因此,在本例中,我们将执行 accents [color_index]
一个小的使用示例:
Text('Hello',
style: TextStyle(color: Colors.accents[0]),
),
redAccent的Colors.accents [0]
谢谢。

关于flutter - 无法将参数类型 'List<MaterialAccentColor>'分配给参数类型 'MaterialColor',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64025518/

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