loadSettingsSync method

void loadSettingsSync(
  1. VoidCallback onLoadEncrypted
)

Load settings synchronously with viewport restoration.

Implementation

void loadSettingsSync(VoidCallback onLoadEncrypted) {
  loadMapSettingsSync(viewportInitialized: viewportInitialized)
      .then((result) {
        if (!mounted) return;

        safeSetState(this, () {
          mapSettings = result.settings;
          if (result.initialCenter != null) {
            initialCenter = result.initialCenter!;
            initialZoom = result.initialZoom!;
            viewportInitialized = result.viewportInitialized;
          }
        });

        // Move map after state update if viewport was loaded.

        if (result.initialCenter != null) {
          mapController.move(result.initialCenter!, result.initialZoom!);
        }

        // Validate encrypted setting if enabled.

        if (result.settings.showEncryptedPlaces) {
          Future.delayed(const Duration(milliseconds: 200), () {
            if (mounted) {
              validateSavedEncryptedSettingAndLoad(onLoadEncrypted);
            }
          });
        }
      })
      .catchError((_) {});
}