I have no issue implementing more simple packages with DDD, but how can I go about implementing the RevenueCat (manages subscriptions in-app purchases) package for flutter using DDD. The issue I have is that it requires their own custom classes (packages) to be passed through the packages functions.
So far I have abstracted it so that the only place my other packages live is inside their repository / facade classes and it's not polluting any other part of my code, I would like to achieve that here as well.
E.g. (excerpt from the packages github repo link, which is at the end of the question)
class UpsellScreen extends StatelessWidget {
final Offerings offerings;
UpsellScreen({Key key, @required this.offerings}) : super(key: key);
@override
Widget build(BuildContext context) {
if (offerings != null) {
final offering = offerings.current;
if (offering != null) {
final monthly = offering.monthly;
final yearly = offering.annual;
if (monthly != null && yearly != null) {
return Scaffold(
appBar: AppBar(title: Text("Upsell Screen")),
body: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
PurchaseButton(package: monthly),
PurchaseButton(package: yearly)
],
)));
}
}
}
return Scaffold(
appBar: AppBar(title: Text("Upsell Screen")),
body: Center(
child: Text("Loading..."),
));
}
}
There is an example of a full implementation that is fairly simple to follow and it's just one file: https://github.com/RevenueCat/purchases-flutter/blob/master/example/lib/main.dart
As I'm new to DDD, I'm not sure the exact way to implement this kind of package and would like to stick with DDD as my design choice as I really enjoy the workflow.