I shipped a Flutter package today called paywall_kit . It has 12 prebuilt paywall screens that you can drop into an app. This post is about the one architecture problem I spent the most time on while building it, because I think it's an interesting little case study even if you never use the package.
The problem
I had 12 different paywall layouts — a carousel one, a comparison table, a lifetime-offer one, etc. — and every single one needs to do the same five things:
Render its own unique layout.
Show a buy button that calls somebody's purchase API.
Show a spinner while the purchase is in flight.
Handle success, failure, and user cancellation.
Wire up a Restore Purchases link (App Store requires it).
Two obvious ways to handle this, both bad:
If I hard-coded the in_app_purchase plugin into each variant, I'd lock everyone who uses the package into that one purchase backend.…