通過設置 StrutStyle 的 leading , 然后利用 Transform 做計算翻方向位置偏移,因為 leading 是上下均衡的,所以計算后就可以得到我們所需要的行間距大小。 (雖然無法保證一定 100%像素准確,你是否還知道其他方法?)
Transform.translate(
offset: Offset(0, 1 / 2), //1為 StrutStyle 的 leading的值
child:Text(
"1.xxxxxxxxxxxxxxxxxxx\n2.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n3.xxxxxxxxxxxxxxxxxxx\n4.xxxxxxxxxxxxxxxxxx",
style: TextStyle(color: Color.fromRGBO(51, 51, 51, 1),fontSize: HspSize.setRpx(28),),
strutStyle: StrutStyle(forceStrutHeight: true, height:1, leading: 1),
),
)
來源:https://blog.csdn.net/qq_42944436/article/details/107914775