initialize static method

Future<void> initialize({
  1. required String flavor,
  2. bool enableMockup = false,
  3. int maxCacheImage = 30,
})

Initialize the configuration.

Runs the first time the app is run.

Implementation

static Future<void> initialize({
  required String flavor,
  bool enableMockup = false,
  int maxCacheImage = 30,
}) async {
  if (isInitialized) {
    return;
  }
  _flavor = flavor;
  _isEnabledMockup = enableMockup;
  _maxCacheImage = maxCacheImage;
  await Prefs.initialize();
  if (!Prefs.containsKey(_uidKey)) {
    Prefs.set(_uidKey, _uid = uuid);
  } else {
    _uid = Prefs.getString(_uidKey);
  }
  if (!Config.isWeb) {
    final deviceInfoPlugin = DeviceInfoPlugin();
    await Future.wait([
      getTemporaryDirectory()
          .then((value) => _temporaryDirectory = value.path),
      getApplicationDocumentsDirectory()
          .then((value) => _documentDirectory = value.path),
      PackageInfo.fromPlatform().then((value) => _packageInfo = value),
      if (Config.isIOS) ...[
        getLibraryDirectory().then((value) => _libraryDirectory = value.path),
        deviceInfoPlugin.iosInfo.then((value) => _iosDeviceInfo = value),
      ],
      if (Config.isAndroid) ...[
        getExternalStorageDirectory().then((value) async {
          if (value == null) {
            _libraryDirectory =
                (await getApplicationDocumentsDirectory()).path;
          } else {
            _libraryDirectory = value.path;
          }
        }),
        deviceInfoPlugin.androidInfo
            .then((value) => _androidDeviceInfo = value),
      ]
    ]);
  }
  _isInitialized = true;
}