initialize method
override
Implementation
@override
Future<void> initialize() async {
logger.info('Starting subscription service init');
if (_initialState != null) {
await _preferences.setBool(
PreferenceKeys.fakeSubscriptionStatus,
_initialState!,
);
}
userId = 'fake';
subscriptionStatus.add(
_preferences.getBool(PreferenceKeys.fakeSubscriptionStatus) ?? false,
);
fetchedPaywalls.addAll({
'onboarding': const Paywall(
id: 'onboarding',
products: [
ProductModel(
id: 'fakeOnbProduct',
subscriptionProps: SubscriptionProps(
period: SubscriptionPeriod.week,
count: 1,
currency: 'USD',
price: 499,
),
name: 'Weekly with trial',
introductorySubscriptionProps: SubscriptionProps(
period: SubscriptionPeriod.day,
count: 3,
price: 0,
currency: 'USD',
),
),
],
),
'special': const Paywall(
id: 'special',
products: [
ProductModel(
id: 'fakeSpecialProduct',
subscriptionProps: SubscriptionProps(
period: SubscriptionPeriod.year,
count: 1,
currency: 'USD',
price: 799,
),
name: 'Special promotion',
),
],
),
'push': const Paywall(
id: 'push',
products: [
ProductModel(
id: 'fakePushProduct',
subscriptionProps: SubscriptionProps(
period: SubscriptionPeriod.year,
count: 1,
currency: 'USD',
price: 1499,
),
name: 'Special promotion',
),
],
),
'normal': const Paywall(
id: 'normal',
products: [
ProductModel(
id: 'fakeMonthProduct',
subscriptionProps: SubscriptionProps(
period: SubscriptionPeriod.month,
count: 1,
currency: 'USD',
price: 1299,
),
name: 'Monthly with trial',
introductorySubscriptionProps: SubscriptionProps(
period: SubscriptionPeriod.day,
count: 3,
price: 0,
currency: 'USD',
),
),
ProductModel(
id: 'fakeWeekProduct',
subscriptionProps: SubscriptionProps(
period: SubscriptionPeriod.week,
count: 1,
currency: 'USD',
price: 499,
),
name: 'Weekly with trial',
introductorySubscriptionProps: SubscriptionProps(
period: SubscriptionPeriod.day,
count: 3,
price: 0,
currency: 'USD',
),
),
ProductModel(
id: 'fakeAnnualProduct',
subscriptionProps: SubscriptionProps(
period: SubscriptionPeriod.year,
count: 1,
currency: 'USD',
price: 3999,
),
name: 'Annual with trial',
introductorySubscriptionProps: SubscriptionProps(
period: SubscriptionPeriod.day,
count: 3,
price: 0,
currency: 'USD',
),
),
],
),
});
if (fetchedPaywalls.isNotEmpty) {
paywallsStream.add(fetchedPaywalls);
}
logger.info('Init success with paywalls ${fetchedPaywalls.keys}');
}