I would like to use the google translate tool to automatically translate the content of a webview, I haven't found any information about it for flutter. I only want to show in the PopupMenuButton of navigation an option of type "translate this page". I would appreciate some guidance.
This is what I have:
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(nameCourse.toString()),
centerTitle: true,
actions: <Widget>[
PopupMenuButton<String>(
onSelected: handleClick,
itemBuilder: (BuildContext context) {
return {
'Translate this page',
'Compartir mediante...',
'Abrir en Chrome',
'Copiar Enlace'
}.map((String choice) {
return PopupMenuItem<String>(
value: choice,
child: Text(choice),
);
}).toList();
},
),
]),
body: WebView(
userAgent: "random",
javascriptMode: JavascriptMode.unrestricted,
initialUrl: urlCourse.toString(),
),
);
}
void handleClick(String value) {
switch (value) {
case 'Copiar Enlace':
copiarEnlace();
break;
case 'Translate thi page':
//translate()
break;
case 'Abrir en Chrome':
openUrl();
break;
case 'Compartir mediante...':
compartirUrl();
break;
}
}