Adding in-app purchases to Flutter apps

Last updated 138 days ago by Joe Birch

flutter

In many applications that we build we want to offer some way to monetize the product. Be it through subscriptions, one-off purchases or upgrades – these all provide a way to offer more value to our users. We’ve long done this through our Android (via Google Play) and iOS (via iTunes) applications, and now that we’re building Flutter apps we want to be able to do the same here too. In this article we’re going to explore the in-app purchase capabilities when it comes to Flutter and learn how to implement these within our own apps.

Note: before we get started it’s important to be aware that this package is in beta. Whilst that’s the case, it is the official package for in-app purchases so is worth migrating when the time comes.


We’re going to begin by adding the in-app purchase package to our list of dependencies in our pub.yaml file:

col 1 | col 2
----- | --------------------------- 1 | in_app_purchase: ^0.1.0+4

When making use of this package there is a core class that we’re going to be interacting with – this is the InAppPurchaseConnection. This is an abstract class which will be used and take the form of either a wrapper for the Google Play Store or the iOS App Store.

The abstract class, InAppPurchaseConnection, provides a collection of abstract methods which each of the inheriting classes will provide platform specific implementations for.

The great thing is that your application will have no idea what one is being used at this point, when you want to access the store connection you retrieve an instance of the class by using InAppPurchaseConnection.instance – at this point in the package, the following code is used:

The great thing is that your application will have no idea what one is being used at this point, when you want to access the store connection you retrieve an instance of the class by using InAppPurchaseConnection.instance – at this point in the package, the following code is used:

Read full Article