Launching a URL from the app

Until now, we have seen how we can use Flutter plugins to add specific features to apps. In the Favors app, for the user profile picture, for example, we have used a plugin that launches the camera app and awaits for an image file: the image_picker plugin. This plugin acts as a bridge for us, and the camera app is independent from the underlying system, as we do not need to know how to launch the camera app and how to take the image file, we just ask it to do the hard work for us. 

Taking a profile picture is a good use of a plugin, as in a future version of the app, we could allow the user to import the image from the gallery and use it in the same way. The image_picker plugin used does this job as well.

Now let's imagine another use case: a user asks a favor from another user that involves accessing a URL to get more context about the favor. For example, if someone asks you to buy a product from an e-commerce website, it's good to share the link to the product so that there isn't any misunderstanding.

Adding the open link functionality to the app can be made with the help of a plugin, url_launcher. The point is, for many features of our apps, we do not need to know how the platform works under the hood, as there are many useful Flutter plugins available to us.

Check out the code for launching URLs from the app on GitHub in the Chapter11|hands_on_url_handler directory.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.58.137.218