从列表的尾部开始删除元素,直到传入的遍历函数返回 true,然后返回剩下的元素。

使用 List.lastIndexWhere() 来遍历执行 test 函数,以找到最后一个满足条件的元素。如果未找到,返回空数据;否则使用 List.sublist() 来返回剩下的元素。

继续阅读 30秒学会 Dart 片段 – dropRightWhile

Returns the symmetric difference between two lists, after applying the provided function to each list element of both.

Use Iterable.toSet() and Iterable.map() to get the unique values in each list after applying fn to them.
Use Iterable.where() in combination with Iterable.contains() to keep only the values in one list and not the other.
Finally, use Iterable.toList() and Iterable.addAll() in combination with the cascade operator (..) to return the result.

继续阅读 30秒学会 Dart 片段 – symmetricDifferenceBy