DrawItemContent.fromJson constructor
DrawItemContent.fromJson(})
Implementation
factory DrawItemContent.fromJson(
Map<String, dynamic> data, {
PaintContent Function(String type, Map<String, dynamic> jsonStepMap)?
contentFactory,
}) {
return DrawItemContent(
size: data['size'] as double,
paintContents: (data['paintContents'] as List<dynamic>).map((dynamic e) {
final String type = e['type'] as String;
final Map<String, dynamic> contentJson = e as Map<String, dynamic>;
switch (type) {
case 'Circle':
return Circle.fromJson(contentJson);
case 'Eraser':
return Eraser.fromJson(contentJson);
case 'Rectangle':
return Rectangle.fromJson(contentJson);
case 'SimpleLine':
return SimpleLine.fromJson(contentJson);
case 'SmoothLine':
return SmoothLine.fromJson(contentJson);
case 'StraightLine':
return StraightLine.fromJson(contentJson);
}
return contentFactory?.call(type, contentJson) ??
EmptyContent.fromJson(contentJson);
}).toList(),
);
}