init method
Future
init({
- required Uri baseUrl,
- required String appName,
- required VChatNotificationType vChatNotificationType,
- VChatNotificationSettings vChatNotificationSettings = const VChatNotificationSettings(),
- VChatWidgetBuilder widgetsBuilder = const VChatWidgetBuilder(),
- required bool enableLogger,
- required String passwordHashKey,
- int maxMediaUploadSize = 50 * 1000 * 1000,
- int maxGroupChatUsers = 512,
baseUrl v chat backend base url
appName your app name to because we create a file in phone internal storage to save files
the folder in Documents/appName
isUseFirebase if firebase not supported in your country or you not connect the app with firebase yet
lightTheme define and override v_chat default Light theme
darkTheme define and override v_chat default Dark theme
navKey nav Key to get the context any where and support localization
maxMediaUploadSize file videos images max size in byes 50 * 1000 * 1000 ~ 50mb
Implementation
Future init({
required Uri baseUrl,
required String appName,
required VChatNotificationType vChatNotificationType,
VChatNotificationSettings vChatNotificationSettings =
const VChatNotificationSettings(),
VChatWidgetBuilder widgetsBuilder = const VChatWidgetBuilder(),
required bool enableLogger,
required String passwordHashKey,
int maxMediaUploadSize = 50 * 1000 * 1000,
int maxGroupChatUsers = 512,
}) async {
///init some service
await VChatAppService.instance
.init(vChatNotificationType: vChatNotificationType);
await LocalStorageService.instance.init();
final appService = VChatAppService.instance;
///set some constants
appService.vChatNotificationType = vChatNotificationType;
appService.vChatNotificationSettings = vChatNotificationSettings;
appService.appName = appName;
appService.maxGroupChatUsers = maxGroupChatUsers;
VChatConfig.serverIp = baseUrl.toString();
VChatConfig.maxMessageFileSize = maxMediaUploadSize;
late bool enableLog;
if (kReleaseMode) {
enableLog = false;
} else {
enableLog = enableLogger;
}
appService.enableLog = enableLog;
appService.passwordHashKey = passwordHashKey;
appService.vcBuilder = widgetsBuilder;
unawaited(_checkVersion());
}