readContent static method

Future<EpubContent> readContent(
  1. EpubContentRef contentRef
)

Implementation

static Future<EpubContent> readContent(EpubContentRef contentRef) async {
  var result = EpubContent();
  result.Html = await readTextContentFiles(contentRef.Html!);
  result.Css = await readTextContentFiles(contentRef.Css!);
  result.Images = await readByteContentFiles(contentRef.Images!);
  result.Fonts = await readByteContentFiles(contentRef.Fonts!);
  result.AllFiles = <String, EpubContentFile>{};

  result.Html!.forEach((String? key, EpubTextContentFile value) {
    result.AllFiles![key!] = value;
  });
  result.Css!.forEach((String? key, EpubTextContentFile value) {
    result.AllFiles![key!] = value;
  });

  result.Images!.forEach((String? key, EpubByteContentFile value) {
    result.AllFiles![key!] = value;
  });
  result.Fonts!.forEach((String? key, EpubByteContentFile value) {
    result.AllFiles![key!] = value;
  });

  await Future.forEach(contentRef.AllFiles!.keys, (dynamic key) async {
    if (!result.AllFiles!.containsKey(key)) {
      result.AllFiles![key] =
          await readByteContentFile(contentRef.AllFiles![key]!);
    }
  });

  return result;
}