Making a Dart package suitable for public use.
No more than four days after publishing my article concerning the Dart package, ads, that utilized Google’s own plugin, firebase_admob, to add Ads to your Flutter app, I’ve began writing another article on somewhat the same subject. I didn’t like the Dart package you see. Now, why was that?
Well, because, as I explained at the end of my previous article, Add Ads to your App in a Snap!, there’s some things one must consider when supplying a program for ‘public consumption’ as it were. I hinted there were some things still outstanding that needed to be addressed. Well, four days on, they’ve been addressed. Again, this was concerns the Dart package, ads. I’ve made it better. That’s why.
For Public Consumption
I made it better to be used in production with unknown mobile apps. I had initially chosen it to be a Utility Class using much of the Singleton design pattern approach when developing this Dart package. In other words, the class was made up of a series of public static properties and public static functions that you can then access application-wide simply by using the class name as prefix, ‘Ads.’ By it’s very nature, there’s only one instance of it as it’s not meant to be instantiated. However, such a class is not without certain considerations. Ones that needed to be addressed with regards to the purpose of this particular class. It was to utilize a Google plugin involving Admob ads. Ads for a lone mobile app.
The Bigger Picture
In this article, it’s not so much about the Dart package itself. That was covered in the previous article, Ads to your App in a Snap! This article will explain why the turnaround from the Utility Class approach to the conventional class instantiation using the classical class constructor. I’ll explain the initial intent, and then I’ll explain why I feel the latest incarnation of the Dart package is more suitable to be used as a general-purpose utility program. One that provides, in this case, a Google plugin to display Admob ads in any sort of Flutter app you can dream of — big or small. By all appearances, it’ll look like any standard class, but there’s a twist. Read on and find out what.