将空项目添加到列表

Add empty item to list

我有以下代码:

List.from((currentState as ItemsLoaded).items)..add();

我想添加一个空项目,然后在 class 项目中分配一个唯一的 uuid。我怎样才能做到这一点?现在它说我需要 add()

的参数

如果您想添加一个空项目,请确保 class 中的字段不是必需的,然后只需

List.from((currentState as ItemsLoaded).items)..add(Item());.

List.from((currentState as ItemsLoaded).items)..add(Item(id: yourUUID));