createSegment method
Creates a new segment for the given page
Implementation
Future<Segment> createSegment(int pageId, SegmentType type, Segment segment) async {
var segmentType = '';
final data = segment.toJson();
switch (type) {
case SegmentType.file:
segmentType = 'file';
data['file'] = segment.file!.id!;
break;
case SegmentType.gallery:
segmentType = 'gallery';
data['gallery'] = segment.gallery!.id!;
break;
case SegmentType.html:
segmentType = 'html';
break;
}
final response = await _post('/api/segment-page/$pageId/segment/$segmentType', data: data);
return Segment.fromJson(response.data);
}