Initialization
SDK Initialization for Wepin Flutter Widget SDK
After installing the Wepin Flutter Widget SDK, the next step is to initialize the SDK. SDK initialization involves creating an instance of WepinWidgetSDK and using the init() function to proceed.
Import SDK
To use the Wepin Flutter Widget SDK, you first need to import the SDK. Add the following import statements:
import 'package:wepin_flutter_widget_sdk/wepin_flutter_widget_sdk.dart';
import 'package:wepin_flutter_widget_sdk/wepin_flutter_widget_sdk_type.dart';Creating the WepinWidgetSDK Instance
Before creating an instance of WepinWidgetSDK, you must register your app's Android/iOS information in the Wepin Workspace.
Using the registered app information, create an instance of WepinWidgetSDK. In the state init stage of the main.dart file, create and initialize the WepinWidgetSDK instance as follows:
WepinWidgetSDK wepinSDK = WepinWidgetSDK(
wepinAppKey: wepinAppKey,
wepinAppId: wepinAppId
);SDK Initialization (init)
When initializing the Wepin Flutter Widget SDK, you can define the required widget properties.
await wepinSDK.init({WidgetAttributes? attributes});Parameters
attributes
<WidgetAttributes>optional - Widget properties to define during initialization.defaultLanguage
<String>: Set the default language of the widget. The default value isko, and currently supported languages areen,jaandko.defaultCurrency
<String>Set the default currency of the widget. The default value isKRW, and currently supported currencies areUSD,JPYandKRW.
Return Value
Future<void>
Example
await wepinSDK.init(WidgetAttributes(
defaultLanguage: 'ko',
defaultCurrency: 'KRW',
));Checking Initialization Status (isInitialized)
You can check whether the WepinSDK has been successfully initialized.
bool isInitialized = wepinSDK.isInitialized();Parameters
None
Return Value
<bool>
Returnstrueif the initialization was successful, andfalseif it failed.
Example
await wepinSDK.init(WidgetAttributes(
defaultLanguage: 'ko',
defaultCurrency: 'KRW',
));
if (wepinSDK.isInitialized()) {
print('WepinSDK is initialized!');
}Changing Language and Currency (changeLanguage)
You can change the language and currency of the widget.
wepinSDK.changeLanguage({String language, String currency});Parameters
language
<String>Specifies the language to be displayed in the widget. Currently supported languages areen,jaandko.currency
<String>Specifies the currency to be displayed in the widget. Currently supported currencies areUSD,JPYandKRW.
Example
wepinSDK.changeLanguage(
language: 'ko',
currency: 'KRW'
);Last updated
Was this helpful?