TextComponent.translate constructor
TextComponent.translate(})
Implementation
TextComponent.translate(
String key, {
/// a List containing a String, TextComponent or another List of TextComponents that replace placeholder values(e.g $s)
List<dynamic>? conversionFlags,
this.color,
this.bold,
this.italic,
this.underlined,
this.strikethrough,
this.obfuscated,
this.clickEvent,
this.hoverEvent,
this.insertion,
String? fallback,
}) {
value = {'translate': key};
if (fallback != null) value['fallback'] = fallback;
if (conversionFlags != null && conversionFlags.isNotEmpty) {
value['with'] = [];
for (var c in conversionFlags) {
if (c is List<TextComponent>) {
value['with'].add(c.map((TextComponent x) => x.toMap()).toList());
}
if (c is TextComponent) value['with'].add(c.toMap());
if (c is String) value['with'].add(TextComponent(c).toMap());
}
}
}