askForUpdate method

Future<bool> askForUpdate()

this method will trigger updateDataLoader for the needed locales and flavors You can use this method to trigger remote download of ARBs files for example Returns true if translations have been updated, false otherwise

Implementation

Future<bool> askForUpdate() async {
  var updated = false;
  if (updateDataLoader != null) {
    final currentLocale = Intl.defaultLocale!;
    final data = await updateDataLoader!(defaultLocale, defaultFlavor);
    if (data != null) {
      try {
        _parseMetaData(data);
        updated = true;
      } catch (e, stack) {
        onError?.call(e, stack);
      }
    }
    if (currentLocale != defaultLocale) {
      final data = await updateDataLoader!(currentLocale, defaultFlavor);
      if (data != null) {
        try {
          _loadLocale(currentLocale, data);
          updated = true;
        } catch (e, stack) {
          onError?.call(e, stack);
        }
      }
    }
    if (_currentFlavor != defaultFlavor) {
      final data = await updateDataLoader!(currentLocale, _currentFlavor);
      if (data != null) {
        try {
          _loadLocale(currentLocale, data, flavor: _currentFlavor);
          updated = true;
        } catch (e, stack) {
          onError?.call(e, stack);
        }
      }
    }
  }
  return updated;
}