-
if i touch it once then it prints out 1 line 123
-
if i touch it many times then it prints out many line 123
-
So how when I touch it many times then it prints out 1 line 123 or exiting _launchUrl
-
When I touch it many times then I also had to go back to that number of times to get rid of _launchUrl
My code here
Hope to get everyone’s help!
final Uri _url = Uri.parse('https://flutter.dev');
....
Future<void> _launchUrl() async {
if (!await launchUrl(_url)) {
throw 'Could not launch $_url';
}
}
...
InkWell(
onTap: () {
_launchUrl;
print('123');
}
)
I tried using the wait function but still not getting the desired result
2
Answers
I fixed it by following way
Create a variable buttonPressed and set it default to false
Inside your onTap you can check if the buttonPressed is set to false. If it is set to false you can set it to true and run your _launchUrl function. After you called _launchUrl you can set it back to false to run it again.
Also mark your onTap as async to use the await keyword