flutter中The element type Widget cant be assigned to the list type InlineSpan是怎么回事?
这个错误通常是因为在使用RichText组件时,将一个Widget类型的组件作为子组件传递给了text属性,但是text属性期望的是一个InlineSpan类型的对象。
要解决这个问题,需要将Widget类型的组件转换成InlineSpan类型的对象。可以使用TextSpan或其他InlineSpan的子类来包装Widget类型的组件。例如:
RichText(
text: TextSpan(
children: [
TextSpan(text: 'Hello'),
WidgetSpan(child: Container(child: Text('World')))
]
)
)
原文地址: https://www.cveoy.top/t/topic/bWay 著作权归作者所有。请勿转载和采集!