Publication constructor
Publication({
- required Manifest manifest,
- Fetcher fetcher = const EmptyFetcher(),
- ServicesBuilder? servicesBuilder,
- Map<
ReadiumCSSName, bool> userSettingsUIPreset = const {}, - String? cssStyle,
Implementation
Publication({
required this.manifest,
this.fetcher = const EmptyFetcher(),
ServicesBuilder? servicesBuilder,
this.userSettingsUIPreset = const {},
this.cssStyle,
}) {
// We use a Ref<Publication> instead of passing directly `this` to the services to prevent
// them from using the Publication before it is fully initialized.
Ref<Publication> pubRef = Ref<Publication>();
servicesBuilder ??= ServicesBuilder.create();
_services = servicesBuilder
.build(PublicationServiceContext(pubRef, manifest, fetcher));
_manifest = manifest.copy(
links: manifest.links +
_services.map((it) => it.links).flatten().toList());
pubRef.ref = this;
}