init method

void init({
  1. required GlobalKey<NavigatorState> appNavigator,
  2. AtSyncUIOverlay? atSyncUIOverlay = AtSyncUIOverlay.dialog,
  3. AtSyncUIStyle? style,
  4. bool? showTextWhileSyncing,
  5. Function? onSuccessCallback,
  6. Function? onErrorCallback,
  7. Function? syncProgressCallback,
  8. Function? onAtSignRemoved,
  9. Color? primaryColor,
  10. Color? backgroundColor,
  11. Color? labelColor,
  12. bool showRemoveAtsignOption = false,
  13. bool startTimer = true,
})

appNavigator is used for navigation purpose atSyncUIOverlay decides whether dialog or snackbar to be shown while syncing style if material or cupertino style to be applied showTextWhileSyncing should text be shown while syncing onSuccessCallback called after successful sync onErrorCallback called after failure in sync syncProgressCallback Notifies the registered listener for the SyncProgress primaryColor,backgroundColor, labelColor will be used while displaying overlay/snackbar. if showRemoveAtsignOption is true, onAtSignRemoved will be called if atSign is removed successfully from device

Implementation

void init({
  required GlobalKey<NavigatorState> appNavigator,
  AtSyncUIOverlay? atSyncUIOverlay = AtSyncUIOverlay.dialog,
  AtSyncUIStyle? style,
  bool? showTextWhileSyncing,
  Function? onSuccessCallback,
  Function? onErrorCallback,
  Function? syncProgressCallback,
  Function? onAtSignRemoved,
  Color? primaryColor,
  Color? backgroundColor,
  Color? labelColor,
  bool showRemoveAtsignOption = false,
  bool startTimer = true,
}) {
  this.onSuccessCallback = onSuccessCallback;
  this.onErrorCallback = onErrorCallback;
  this.syncProgressCallback = syncProgressCallback;
  this.onAtSignRemoved = onAtSignRemoved;
  AtSyncUI.instance.setAppNavigatorKey(appNavigator);

  /// change status to notStarted
  _atSyncUIListenerSink.add(AtSyncUIStatus.notStarted);

  if (style != null) {
    atSyncUIStyle = style;
  }
  if (atSyncUIOverlay != null) {
    this.atSyncUIOverlay = atSyncUIOverlay;
  }
  this.showTextWhileSyncing = showTextWhileSyncing ?? true;
  this.showRemoveAtsignOption = showRemoveAtsignOption;

  AtSyncUI.instance.configTheme(
    primaryColor: primaryColor,
    backgroundColor: backgroundColor,
    labelColor: labelColor,
    style: style,
  );

  var _atSyncUIController = AtSyncUIController();
  AtSyncUI.instance.setupController(controller: _atSyncUIController);
  syncService = AtClientManager.getInstance().atClient.syncService;
  syncService!.addProgressListener(this);
  // ignore: deprecated_member_use
  syncService!.setOnDone(_onSuccessCallback);

  // ignore: deprecated_member_use_from_same_package
  sync(atSyncUIOverlay: atSyncUIOverlay!, startTimer: startTimer);
}