From 4425c47b69d2cf06ecc7d223942aacbd08b9a1ab Mon Sep 17 00:00:00 2001 From: Vadim <44135514+vodemn@users.noreply.github.com> Date: Sat, 27 Jan 2024 22:39:48 +0100 Subject: [PATCH] fixed `showBuyProDialog` test --- lib/providers/services_provider.dart | 6 ++++-- .../pro_features_dialog/widget_dialog_pro_features.dart | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/providers/services_provider.dart b/lib/providers/services_provider.dart index 36f5674..1db019e 100644 --- a/lib/providers/services_provider.dart +++ b/lib/providers/services_provider.dart @@ -31,8 +31,10 @@ class ServicesProvider extends InheritedWidget { required super.child, }); - static ServicesProvider of(BuildContext context) { - return context.findAncestorWidgetOfExactType()!; + static ServicesProvider of(BuildContext context) => ServicesProvider.maybeOf(context)!; + + static ServicesProvider? maybeOf(BuildContext context) { + return context.findAncestorWidgetOfExactType(); } @override diff --git a/lib/screens/shared/pro_features_dialog/widget_dialog_pro_features.dart b/lib/screens/shared/pro_features_dialog/widget_dialog_pro_features.dart index 50cca42..3b8d4f2 100644 --- a/lib/screens/shared/pro_features_dialog/widget_dialog_pro_features.dart +++ b/lib/screens/shared/pro_features_dialog/widget_dialog_pro_features.dart @@ -46,8 +46,8 @@ class ProFeaturesDialog extends StatelessWidget { FilledButton( onPressed: () { _close(context).then((_) { - ServicesProvider.of(context) - .analytics + ServicesProvider.maybeOf(context) + ?.analytics .setCustomKey('iap_product_type', IAPProductType.paidFeatures.storeId); IAPProductsProvider.maybeOf(context)?.buy(IAPProductType.paidFeatures); });