removeTranslation method

Future<void> removeTranslation(
  1. BuildContext context,
  2. Translation translation
)

Removes a translation and updates the manager's state.

context is the build context, used to mark the widget tree as needing a rebuild. translation is the translation to remove.

Implementation

Future<void> removeTranslation(
    BuildContext context, Translation translation) async {
  Map<String, dynamic> json = await loader.loadTranslation(translation,
      supportedLocales: supportedLocales);
  List<String> keysToRemove = json.keys.toList();

  for (var key in keysToRemove) {
    _localizedStrings.remove(key);
    logger.log("Removed key: $key from translation: ${translation.name}",
        type: LogType.info);
  }

  loader.removeTranslation(translation.name);
  logger.log("Translation removed: ${translation.name}", type: LogType.info);

  (context as Element).markNeedsBuild();
}