首页 > 解决方案 > 如何知道 SwitchListTile 中的字幕是否为两行或多行?

问题描述

有一个名为isThreeLinein的属性SwitchListTile。我想将其值设置为true仅当我的字幕长度为两行或多行时。我怎么知道?

SwitchListTile(
  value: true,
  title: Text('Title'),
  subtitle: Text('This is going to be a subtitle which is two lines long with isThreeLine: true'),
  isThreeLine: false, // only set it to true when my subtitle is 2 or more lines long. 
  onChanged: null,
)

在此处输入图像描述

在此处输入图像描述


注意:我不是在寻找任何解决方法,比如玩字符串的总长度等。

标签: flutterflutter-layout

解决方案


推荐阅读