如何在Map中使用fromJson列表?

问题描述 投票:0回答:1

通常,我将使用此代码进行列表。

jsonMap.map((gallery) => new Gallery.fromJson(gallery)).toList();

但我不知道如何使用fromJson。

This is a picture of my code.

dart flutter
1个回答
1
投票

我通过使用解决了这个问题。

List.castFrom(json['galleries']).map((gallery) => new Gallery.fromJson(gallery)).toList();
© www.soinside.com 2019 - 2024. All rights reserved.