evaluate method

Future<RouteBase?> evaluate(
  1. BuildContext context
)

Implementation

Future<RouteBase?> evaluate(BuildContext context) async {
  if (_initializedInstance != null) {
    return _initializedInstance;
  }

  final value = (await condition?.execute(context)) ?? defaultCase;
  final caseItem = (cases ?? []).firstWhereOrNull((x) => x.value == value);

  final ref = caseItem?.item;
  RouteBase? leafRoute;

  if (ref != null) {
    final route = await vyuh.content.provider.fetchRoute(routeId: ref.ref);
    leafRoute = await route?.init();
  }

  _initializedInstance = leafRoute;
  return _initializedInstance;
}