DyteProvider
A foundational widget designed to initialize and provide the necessary Ospi environment for a Flutter application. The DyteProvider acts as a context wrapper that sets up design tokens, client configurations, and UI Kit information required for Ospi components. It ensures that Ospi functionalities are available and properly initialized throughout the widget tree where it's used.
Usage
To use DyteProvider, wrap the root of your application:
DyteProvider(
client: dyteMobileClientInstance,
uiKitInfo: dyteUIKitInfoInstance,
child: MaterialApp(
// Your app's home screen or an entry widget
home: YourAppHome(),
),
)
if you don't want to wrap the root of your app inside DyteProvider, you can also wrap a specific part of your app where you want to use Ospi components but after adding DyteProvider you need a MaterialApp widget under it.
This approach ensures that all the necessary Ospi setup is done before your app UI starts, allowing you to utilize Ospi features seamlessly within your application.
Properties
child: (Required) The widget below this widget in the tree. This is usually your MaterialApp or your application's home widget.client: (Required) An instance ofDyteMobileClient. This represents the Ospi client configuration that includes authentication and other essential settings.uiKitInfo: (Required) An instance ofDyteUIKitInfo. This holds information related to the Ospi UI Kit such as design tokens and other UI configurations.
Notes
Ensure that the DyteMobileClient and DyteUIKitInfo are properly configured before passing them to the DyteProvider. This is crucial for the proper functioning of all Ospi-related components within your application.
Example
Here is an example of using DyteProvider in an application:
class MyApp extends StatelessWidget {
Widget build(BuildContext context) {
return DyteProvider(
client: DyteMobileClient(
// Ospi client configuration
),
uiKitInfo: DyteUIKitInfo(
// UI Kit information and design tokens
),
child: MaterialApp(
home: HomeScreen(),
),
);
}
}
By wrapping your app with DyteProvider, you ensure that all necessary Ospi setups are initialized and available for your app components, allowing you to build a fully functional Ospi-enabled application.