1
例如,我可能在目前的widget树一个富文本,看起来像有没有一种简单的方法可以在Flutter测试中查找由RichText构建的特定文本?
new RichText(
text: new TextSpan(
text: 'Hello ',
style: DefaultTextStyle.of(context).style,
children: <TextSpan>[
new TextSpan(text: 'bold', style: new TextStyle(fontWeight: FontWeight.bold)),
new TextSpan(text: ' world!'),
],
),
)
我尝试使用find.text('Hello bold world!')
,但它不工作,因为它不是一个文本。
谢谢!我喜欢第二种解决方案。 –