this scope gives me Instance of _Future but I want to get that translated text.
Future<dynamic> translate(String input) async {
final translator = GoogleTranslator();
var result;
var translation = await translator
.translate(input, to: 'tr')
.then((value) => {result = value});
return result;
}
Does this work? I guess the
.translate
function returns anTranslate
instance. You need thetext
attribute to get aString
Below code is wrong!
Also you use a
then
clause and getting the result of translation in tovalue
so you don't need to useawait
and set the vartranslation
in this case. Or you can useawait
and remove thethen
. But you should not use bothawait
andthen
for the same async method.So the below code should be used: