init method

Future<void> init()

Initialize settings. Must be called before using any settings.

Implementation

Future<void> init() async {
  if (_initialized) return;
  _initialized = true;

  _preferences ??= await SharedPreferences.getInstance();
  _packageInfo ??= await PackageInfo.fromPlatform();

  _appName = _packageInfo!.appName;
  _packageName = _packageInfo!.packageName;
  _version = _packageInfo!.version;
  _buildNumber = _packageInfo!.buildNumber;

  await localApplicationPath;
  await carpBasePath;

  debug('$runtimeType - Shared Preferences:');
  _preferences!
      .getKeys()
      .forEach((key) => debug('[$key] : ${_preferences!.get(key)}'));

  // setting up time zone settings
  tz.initializeTimeZones();
  try {
    _timezone = await FlutterTimezone.getLocalTimezone();
  } catch (_) {
    _timezone = tz.local.name;
    warning(
        'Could not get the local timezone - setting timezone to $timezone');
  }
  info('Time zone set to $timezone');
  info('$runtimeType initialized');
}