I'm getting too many requests (error: 429) when using the translator API in Flutter. How do i solve this

Viewed 696

I translate the words in the text using onTap, but after a while I get an error because there are too many requests. How can I solve this? If I need to use the sleep function, how do I use it?

"onTap: () {

                        appState.translator
                            .translate(e, from: 'tr', to: 'en')
                            .then((val) {
                           Fluttertoast.showToast(msg: val.text);
                           
                                                    
                       }); "
1 Answers

maybe you should make the onTap as async and await for your Translator , like this :

onTap: () async {

                       await appState.translator
                            .translate(e, from: 'tr', to: 'en')
                            .then((val) {
                           Fluttertoast.showToast(msg: val.text);
                           
                                                    
                       }); 
Related