如何在颤抖中获得想要的单词

时间:2020-09-04 03:59:34

标签: flutter

假设我有这个String变量:

String addressLine = "Mumbai - Pune Expy, Gold Valley Sector D, Tungarli, Lonavla, Maharashtra 410403, India"

我只想显示Mumbai - Pune Expy, Gold Valley Sector D

如何实现这样的目标,以及地址行是否也不同。

预先感谢

1 个答案:

答案 0 :(得分:1)

您可以使用dart中的split()功能:

String addressLine = "Mumbai - Pune Expy, Gold Valley Sector D, Tungarli, Lonavla, Maharashtra 410403, India"
List<String> newList = addressLine.split(', ');
print(newList[0]);   // Will give "Mumbai - Pune Expy"