save method

Future<bool> save()

Implementation

Future<bool> save() async {
  final UContentResponse? p = editing;
  final List<UContentItem> itemModels = items.map((UAdminContentItemForm e) => e.toModel()).toList();
  final List<UContentLink> linkModels = links.map((UAdminContentLinkForm e) => e.toModel()).toList();
  return await send(
    p == null
        ? UServices.content.create(
            p: UContentCreateParams(
              tags: <int>[tag.number],
              title: titleController.text.nullIfEmpty(),
              subTitle: subTitleController.text.nullIfEmpty(),
              description: descriptionController.text.nullIfEmpty(),
              detail1: detail1Controller.text.nullIfEmpty(),
              detail2: detail2Controller.text.nullIfEmpty(),
              imageBase64: imageBase64,
              iconBase64: iconBase64,
              buttonText: buttonTextController.text.nullIfEmpty(),
              buttonLink: buttonLinkController.text.nullIfEmpty(),
              link: linkController.text.nullIfEmpty(),
              order: int.tryParse(orderController.text),
              instagram: instagramController.text.nullIfEmpty(),
              telegram: telegramController.text.nullIfEmpty(),
              whatsapp: whatsappController.text.nullIfEmpty(),
              phone: phoneController.text.nullIfEmpty(),
              items: itemModels,
              links: linkModels,
            ),
          )
        : UServices.content.update(
            p: UContentUpdateParams(
              id: p.id,
              tags: <int>[tag.number],
              title: titleController.text.nullIfEmpty(),
              subTitle: subTitleController.text.nullIfEmpty(),
              description: descriptionController.text.nullIfEmpty(),
              detail1: detail1Controller.text.nullIfEmpty(),
              detail2: detail2Controller.text.nullIfEmpty(),
              imageBase64: imageBase64,
              iconBase64: iconBase64,
              buttonText: buttonTextController.text.nullIfEmpty(),
              buttonLink: buttonLinkController.text.nullIfEmpty(),
              link: linkController.text.nullIfEmpty(),
              order: int.tryParse(orderController.text),
              instagram: instagramController.text.nullIfEmpty(),
              telegram: telegramController.text.nullIfEmpty(),
              whatsapp: whatsappController.text.nullIfEmpty(),
              phone: phoneController.text.nullIfEmpty(),
              items: itemModels,
              links: linkModels,
            ),
          ),
    read,
  ) !=
      null;
}