adaptyteam / AdaptySDK-Flutter

SDK for growing mobile in-app purchases
https://docs.adapty.io/docs/quickstart
MIT License
95 stars 17 forks source link

Make Adapty a singleton #42

Closed layerzzzio closed 2 years ago

layerzzzio commented 2 years ago

Adapty is currently only like a namespace for several functions and has several static functions. As the functions are static it makes it hard to mock Adapty to write tests.

Would be better to adopt something like: https://github.com/FirebaseExtended/flutterfire/blob/master/packages/cloud_firestore/cloud_firestore/lib/src/firestore.dart

This would allow to mock and verify calls to Adapty, like:

verify(mockAdapty.whateverFunction(); verifyNoMoreInteractions(mockAdapty.whateverFunction);

x401om commented 2 years ago

Hi, @layerzzzio! Thanks for the idea, it seems pretty reasonable and interesting. At the moment, the public interface of the Flutter SDK is completely the same on iOS and Android, but there will probably be significant changes on both in the near future. We will try to design the interface in a way that satisfies your request and solves the issue of automatic testing :)