fromRoute static method

DocumentBuilder<RouteBase> fromRoute({
  1. Key? key,
  2. Uri? url,
  3. String? routeId,
  4. required Widget buildContent(
    1. BuildContext,
    2. RouteBase
    ),
  5. bool includeDrafts = false,
  6. bool allowRefresh = true,
  7. bool isLive = false,
})

Creates a DocumentBuilder that fetches a route by path or ID.

Implementation

static DocumentBuilder<RouteBase> fromRoute({
  Key? key,
  Uri? url,
  String? routeId,
  required Widget Function(BuildContext, RouteBase) buildContent,
  bool includeDrafts = false,
  bool allowRefresh = true,
  bool isLive = false,
}) {
  assert(
    (url != null && routeId == null) || (url == null && routeId != null),
    'Either url or routeId must be provided, but not both.',
  );

  return DocumentBuilder<RouteBase>(
    key: key,
    fetchDocument: () => vyuh.content.provider.fetchRoute(
      path: url?.path,
      routeId: routeId,
    ),
    liveDocument: isLive
        ? vyuh.content.provider.live.fetchRoute(
            path: url?.path,
            routeId: routeId,
            includeDrafts: includeDrafts,
          )
        : null,
    initDocument: (context, document) async {
      return await document.init(context);
    },
    buildContent: buildContent,
    allowRefresh: allowRefresh,
    isLive: isLive,
  );
}