When the exception was thrown, this was the stack:
#0 SimpleTranslator._decodeFromMap (package:flutter_i18n/utils/simple_translator.dart:50:62)
#1 SimpleTranslator._translateWithKeyFallback (package:flutter_i18n/utils/simple_translator.dart:41:11)
#2 SimpleTranslator.translate (package:flutter_i18n/utils/simple_translator.dart:24:26)
#3 FlutterI18n.translate (package:flutter_i18n/flutter_i18n.dart:107:29)
修改calculateSubmap函数
Map<dynamic, dynamic> calculateSubmap(final String translationKey) {
final List<String> translationKeySplitted =
translationKey.split(this.keySeparator!);
translationKeySplitted.removeLast();
Map<dynamic, dynamic> decodedSubMap = decodedMap ?? Map(); // here changed
translationKeySplitted.forEach((listKey) =>
decodedSubMap = (decodedSubMap)[listKey] ?? Map());
return decodedSubMap;
}
网友评论