I implemented a translator for a specific outcome. My issue is that I receive an error message when I need to expand the translation reference
Exception has occurred. _TypeError (type 'String' is not a subtype of type 'int' of 'index')
working codes
final translator = GoogleTranslator();
var value1;
void initContent() async {
value1 = await translator.translate(
widget.results[0]['meanings']['light'].join('\n\n'),
to: 'fr',
);
not working codes with failure
final translator = GoogleTranslator();
var value1;
void initContent() async {
value1 = await translator.translate(
widget.results[0]['name']['meanings']['light'].join('\n\n'),
to: 'fr',
);
source json file
"name": "Queen of Wands",
"meanings": {
"light": [
"Paying close attention",
"Helping others focus on the issue at hand",
"Getting everyone to work together",
"Identifying common ground",
"Bringing people together, despite their differences",
"Using reverse psychology"
],
},
]
CodePudding user response:
It should be just ['name']
like:
value1 = await translator.translate(
widget.results[0]['name'],
to: 'fr',
);