Copy cURL from DevTools in Flutter
Earlier we did not have an inbuilt way of copying cURL from Flutter, now we can easily do it using DevTool. In this article, we are going to learn exactly that.
In this article, we will learn how to copy the cURL request from DevTools in Flutter. The video version of this article is also available on YouTube.
Copying an API Request as curl
First, open the DevTool from your IDE, then open the network tab in the DevTool. In the network tab, we will see our app API requests and responses in the list.
To copy the cURL of any request, click on the more icon and then click on Copy as cURL button. That’s it.
Now we can test our cURL in two ways.
Testing it on Terminal
If you want to test it, open the terminal, paste the copied cURL, and hit enter. Now we see the response of the API in the terminal.
Importing cURL in Postman
If you want to import your cURL inside Postman, click on the import button on the top-left corner, and paste the cURL request which we copied from DevTool, and then we will see that the API request is being imported and ready to use with all details populated automatically in API tab. Hit send and we will see the API response in Postman.
Conclusion
Earlier we did not have an inbuilt way of copying cURL from Flutter now we can easily do so using DevTool. This helps us to easily debug the API outside our mobile app and allows us to easily debug any specific user-related issue since we can directly get the Auth token and necessary headers from cURL.
That's it, folks!!
If you have any questions, please let me know in the comments, and don't forget to subscribe to stay tuned for upcoming tips and tricks in Flutter.
You can also follow me on Twitter for any updates.