vyuh_core library

Core library for Vyuh applications. This library provides essential functionalities for building Vyuh apps, including a way to organize features with FeatureDescriptor and leveraging the Plugin interface for interacting with third-party integrations such as Authentication, Content Management, Networking, Dependency Injection, Analytics, etc. Key Features:

  • Plugin System: A flexible plugin architecture allows extending Vyuh with custom features and integrations. See Plugin for more details.
  • Modular Features: Organize features with FeatureDescriptor and build Apps in a composable manner. Features are atomic, transferable between Vyuh Apps and provide a decentralized approach for building large scale Apps.
  • Platform Widgets: Provides a mechanism to supply your own Widgets for loaders, error-views and other types of visual branding. See VyuhPlatform and PlatformWidgetBuilder. Getting Started: To use this library, import it into your Dart code:
import 'package:vyuh_core/vyuh_core.dart';

Then, you can initialize the features and plugins.

  runApp(
    initialLocation: '/',
    plugins: PluginDescriptor(
      content: DefaultContentPlugin(
        provider: SanityContentProvider.withConfig(
          config: SanityConfig(
            projectId: '<your-project-id>',
            dataset: 'production',
            perspective: Perspective.previewDrafts,
            useCdn: false,
            token: '<your-token>',
          ),
          cacheDuration: const Duration(seconds: 5),
        ),
      ),
      env: vc.DefaultEnvPlugin(),
      auth: MyCustomAuthPlugin(),
      telemetry:
          vc.TelemetryPlugin(providers: [vc.ConsoleLoggerTelemetryProvider()]),
    ),
    features: () => [
      // Core Vyuh features that are necessary for all apps
      system.feature,
      developer.feature,

      // Example Features
      root.feature,
      counter.feature,
      onboarding.feature,
      auth.feature(),
    ],
  );

Classes

AnalyticsPlugin
The default implementation of analytics tracking in Vyuh applications.
AnalyticsProvider
The base interface for an Analytics Provider. The provider is responsible for reporting analytics events, errors, and messages.
AuthPlugin
An authentication plugin that supports various authentication methods.
Category
A category for organizing routes.
CMSRoute
A route purely meant to identify CMS pages. Use it to distinguish between the way local routes and CMS routes are handled.
ContainerItem
Represents a container item that can contain other content items.
ContentItem
The base class for all content items in Vyuh.
ContentModifierConfiguration
Configuration for modifying content presentation.
ContentPlugin
The base class for a Content Plugin
ContentProvider
DefaultEnvPlugin
DefaultEventPlugin
Default implementation of EventPlugin using the event_bus package.
DefaultNavigationPlugin
DIPlugin
DIPlugin is an abstract class that extends the Plugin class.
DocumentItem
The base interface for all schema-driven document items.
EnvPlugin
An abstract class representing an environment plugin. It provides methods to interact with environment variables.
EventPlugin
Base class for implementing event handling in Vyuh applications.
ExtensionBuilder<T extends ExtensionDescriptor>
The base type for all extension builders. An extension builder is responsible for building an extension, by assembling all of the extension descriptors.
ExtensionDescriptor
The base type for all extension descriptors. An ExtensionDescriptor provides configurability for an extension.
FeatureDescriptor
The essential descriptor for a feature. A feature descriptor provides the necessary information to register a feature within the framework.
FeatureFlagPlugin<TSettings, TContext>
The base class for a Feature Flag plugin. Feature Flags are useful to control the visibility of features in an application. They are setup on the server side and can be controlled by the server to enable/disable features for different users.
FileReference
A reference to a file asset in the content management system.
GetItDIPlugin
GetItDIPlugin is a class that is final and it extends the DIPlugin. It uses the 'GetIt' package to manage dependency injection in the project.
HttpNetworkConfig
HttpNetworkPlugin
ImageReference
A reference to an image asset in the content management system.
LayoutConfiguration<T extends ContentItem>
Base class for configuring the visual layout of a content item.
LiveContentProvider
An interface for plugins that provide live content.
Logger
NetworkPlugin
Base class for implementing network communication in Vyuh applications.
NoOpAnalyticsProvider
A no-op implementation of AnalyticsProvider.
NoOpContentPlugin
NoOpContentProvider
NoOpLiveContentProvider
A no-op implementation of LiveContentProvider. Is used internally to ensure the Developer is using it correctly by giving proper errors and hints
NoOpTelemetryProvider
A no-op implementation of TelemetryProvider that can be used for development or testing purposes.
NoOpTrace
A no-op implementation of Trace that can be used for development or testing.
ObjectReference
A reference to any content object in the content management system.
PlatformWidgetBuilder
A builder for platform-specific widgets used throughout the Vyuh application.
Plugin
PluginDescriptor
A descriptor for configuring the plugin system in a Vyuh application.
RootItem
Represents a root item that is the root of a content tree.
RouteBase
Base class for all route content items in Vyuh.
RouteLifecycleConfiguration
Configuration for managing route lifecycle events.
RouteTypeConfiguration
Configuration for how a route should be presented.
RoutingConfigNotifier
SchemaItem
The base interface for all schema-driven content items.
SecureStoragePlugin
Base class for implementing secure storage in Vyuh applications.
StoragePlugin
Base class for implementing persistent storage in Vyuh applications.
SystemInitTracker
A tracker for the system initialization process.
SystemReadyEvent
An event indicating that the system is ready.
TelemetryPlugin
The default implementation for a Telemetry Plugin.
TelemetryProvider
The base interface for an Telemetry Provider. The provider is responsible for reporting telemetry events, errors, and messages.
Trace
The base interface for a Telemetry Trace. The trace is responsible for tracking the duration of an operation, and reporting metrics and attributes.
TypeDescriptor<T>
Describes a schema type and its serialization behavior.
Unknown
User
Represents a user of the application.
VyuhBinding
VyuhEvent<T>
Base class for all events in a Vyuh application.
VyuhPlatform
The base class for the Vyuh Platform. This class is responsible for initializing the platform and managing the lifecycle of the platform.

Enums

FieldName
InitState
The possible states of the system initialization.
LoginMethod
Represents the method used to login.
LogLevel
OAuthType

Mixins

InitOncePlugin
A mixin to mark any plugin to be loaded only once after the Platform has been initialized. This mixin can be used together with PreloadedPlugin to ensure that the plugin is loaded at the correct time in the initialization sequence.
PreloadedPlugin
A mixin to mark any plugin to be loaded before the Platform.

Extensions

AsyncLazyDI on DIPlugin
An extension on the DIPlugin class to provide asynchronous lazy dependency injection.
LoggerInterface on VyuhBinding
A convenience wrapper to provide a Logger interface to the Telemetry reportMessage() calls.
NamedBindings on VyuhBinding
NamedPlugins on VyuhPlatform
Provides convenient accessors for named plugins within the Vyuh platform.
PlatformLoggerInterface on VyuhPlatform
Restartable on VyuhPlatform
Restart the platform, re-running the initialization process.

Properties

messages Map<String, String Function(String _)>
final
vyuh VyuhPlatform
The platform interface for Vyuh. This tracks the instance of the platform and can be used to access various aspects of the framework.
getter/setter pair

Functions

debugAssertOneOfPathOrRouteId(String? path, String? routeId) → void
Asserts only one of path or routeId is provided and not both. Asserts that only one of path or routeId is provided.
defaultRoutePageBuilder(BuildContext context, GoRouterState state, {Widget transitionsBuilder(BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation, Widget child)?, Duration? transitionDuration}) Page
The default page builder for CMS routes.
listFromJson<T extends SchemaItem>(dynamic json) List<T>?
Converts a JSON list to a nullable-list of SchemaItem instances of type T.
readValue(dynamic json, String key) Object?
Reads a value from a JSON object using the provided key.
runApp({required FeaturesBuilder features, PluginDescriptor? plugins, PlatformWidgetBuilder? platformWidgetBuilder, String? initialLocation}) → void
The main entry point to kick off the Vyuh Application. This function should be called from the main function of the application. It initializes the Vyuh Platform and runs the application with given features and plugins.
typeFromFirstOfListJson<T extends SchemaItem>(dynamic json) → T?
Converts a JSON object to a nullable-instance of SchemaItem of type T.

Typedefs

AppBuilder = Widget Function(VyuhPlatform platform)
A builder for root Widget of the application. Typically this would be a MaterialApp or CupertinoApp.
CMSPathResolver = String Function(String path)
A function that resolves a CMS path from a local path. This is useful when multiple local routes use a single template path on the CMS. For example: (Local path) /blog/:slug -> /blog (CMS path)
DisposeFunction = void Function()
A function that can be called to dispose of (cancel) an event subscription.
ErrorViewBuilder = Widget Function(BuildContext context, {dynamic error, VoidCallback? onRetry, String? retryLabel, bool showRestart, StackTrace? stackTrace, String? subtitle, required String title})
A builder for an error view widget.
FeaturesBuilder = FutureOr<List<FeatureDescriptor>> Function()
The builder function that creates a set of features.
FromJsonConverter<T> = T? Function(Map<String, dynamic> json)
Function type for converting JSON data to a typed object.
ImagePlaceholderBuilder = Widget Function(BuildContext context, {double? height, double? width})
A builder for an image placeholder widget.
Loader = Widget Function(BuildContext context)
A builder for a widget that is shown when the app is loading.
RouteBuilderFunction = FutureOr<List<RouteBase>?> Function()
A function that returns a list of routes.
RouteErrorViewBuilder = Widget Function(BuildContext context, {dynamic error, VoidCallback? onRetry, String? retryLabel, StackTrace? stackTrace, String? subtitle, required String title})
A builder for a route error view widget.
RouteLoader = Widget Function(BuildContext context, [Uri? url, String? routeId])
A builder for a widget that is shown when a route is loading.
VoidFutureFunction = Future<void> Function()
A function that returns a void Future.
VyuhEventListener<T extends VyuhEvent> = void Function(T event)
A function that handles events of type T.

Exceptions / Errors

AuthException
Base type for all Authentication related exceptions.
CreateUserFailure
Exception thrown when creating a user fails.
DeleteAccountFailure
Exception thrown when the account deletion fails.
LoginMethodCanceled
Exception thrown when a login method is canceled.
LoginMethodFailure
Exception thrown when a login method fails.
LogoutFailure
Exception thrown when the logout fails.
SendEmailLinkFailure
Exception thrown when sending an email-link for logging in.
SendPasswordResetEmailFailure
Exception thrown when sending a password reset email.