dartins 0.2.1+1

Dartins #

Cordova/PhoneGap plugin definitions for use in Dart projects.

Generally speaking, any interactions with plugins should happen after the "deviceReady" event has fired. See example for a simple implementation.

Supported plugins #

  • Device (these are all properties)
    • cordova
    • model
    • platform
    • uuid
    • version
    • manufacturer
    • isVirtual
    • serial
  • Splashscreen
    • show();
    • hide();
  • AdMob Pro - Note! This plugin takes 2% of your revenue if you don't buy a license. For this reason, I'm deprecating support for it
    • Please see the next section on a replacement
  • AdMob - forked from AppFeel
    • Forked to remove 2% revenue stealing
    • Will be kept up to date as necessary
    • To install, see the plugin's README
  • In-app Purchase
    • ProductEvent when(String v);
    • refresh();
    • order(String v);
    • ready(Function v);
    • register(StoreProduct product);
  • Google Analytics
    • startTrackerWithId(String v);
    • trackView(String v);
    • trackEvent(String category, String action, [String label, num v]);
    • trackException(String description, bool fatal);
    • trackTiming(String category, num intervalInMilliseconds, String v, String label);
    • addTransaction(String id, String affiliation, num revenue, num tax, num shipping, String currencyCode);
    • addTransactionItem(String id, String name, String sku, String category, num price, num quantity, String currencyCode);
    • addCustomDimension(String key, String value, [Function success, Function error]);
    • setUserId(String id);
    • debugMode();
    • enableUncaughtExceptionReporting(bool enable, [Function success, Function error]);
  • In-app Browser
    • InappBrowser open(String url, String target, [String options]);
    • addEventListener(String eventname, Function cb);
    • removeEventListener(String eventname, Function cb);
    • close();
    • show();
    • executeScript(InjectDetails details, Function cb);
    • insertCSS(InjectDetails details, Function cb);
  • Amazon Mobile Ads
    • See additional notes below
    • All ad methods are supported.
    • Events are supported
  • Statusbar
    • All methods and properties supported
  • Facebook
    • All methods supported
    • Facebook's official plugin has been abandoned, this plugin is an active, up-to-date fork.
    • To support every option, please use at least version 1.7.2
  • App Settings
    • Fully supported
    • AppSettingsHelper class to provide ease-of-use
  • Network Information
    • Fully supported
    • Connection types are available on ConnectionTypes
    • Event names are constants in the connection class
  • Microsoft CodePush
    • Basic functionality supported
  • iOS AVAudioSession
    • Fully supported

Amazon Ads Specific Notes #

Amazon doesn't make it easy to integrate Cordova with their ad platform but here's some notes.

With this package, there is an "AmazonAds" class that has a developer-friendly interface to the plugin. You should see if that meets your needs before going directly to the methods in "amazon_mobile_ads.dart".

To install the plugin, you'll have to download it from Amazon and install it manually. It's not in npm (so you can't do cordova plugin add <>)

Installation #

Edit your pubspec.yaml file:

  dartins: ^0.2.1

Then run pub get

Dependencies #

The only dependencies outside of Dart are the plugins themselves. You only need to install the plugins you wish to use.

For example, if you want to use the Device plugin, but no others, simply run:

cordova plugin add cordova-plugin-device

Compilation #

To build for Cordova/PhoneGap, the steps are as follows:

  1. Run pub build
  2. Copy the contents of the build folder into the www folder in your Cordova project
  3. Run cordova run android (substitute the Cordova command for your setup).

If you're using PhoneGap Build, you don't need any extra setup to be able to use this package. Just do steps 1 and 2 and then submit your build (make sure you set up the plugins correctly!).

Usage #

A simple usage example:

import 'dart:html';
import 'package:dartins/dartins.dart';

main() {

        //Device Example
        var currentPlatform = Device.platform;
        print('Currently using a ${currentPlatform} device');

        //Splashscreen Example

        //AdMob example
        AdMob.createBanner(new BannerOptions(
            adId: 'cx-xxx',
            position: AdMobPosition.BOTTOM_CENTER.index,
            isTesting: Device.UUID == '123123',
            overlap: true

        //Store example
        Store.register(new StoreProduct(id: 'product1', type: StoreProduct.NON_CONSUMABLE));
        Store.when('product1').approved(allowInterop((var product){
            print('Successfully bought product1');
        Store.when('product1').owned(allowInterop((var product){
            print('Owns product1');

        //Analytics example
        GoogleAnalytics.trackEvent('AppState', 'started');

        //In-app browser example
        InappBrowser iab = InappBrowser.open('http://google.com', InappBrowser.TARGET_BLANK);

Changelog #

0.2.1+1 #

  • Fix dartanalyzer hints

0.2.1 #

  • Change Admob plugin
  • Replace JSON hack with dartify utility

0.2.0 #

  • Updated to Dart 2.0

0.1.5 #

0.1.4 #

  • Switch AVAudioSession plugin to use a new fork
  • Bug fixes for CodePush

0.1.3+2 #

  • Fixed the actual bug I was seeing with getCurrentPackage and getPendingPackage.

0.1.3+1 #

  • Fixed bug with checkForUpdate and notifyApplicationReady. Apparently CodePush will call the callbacks multiple times.

0.1.3 #

  • Added support for the CodePush plugin

0.1.2 #

  • Added support for the Network Information plugin

0.1.1 #

  • Added support for App Settings plugin

0.1.0 #

  • BREAKING CHANGE: The AdMob Pro plugin forces a 2% donation, as a result, I'm deprecating the API. It's now called "AdMobPro". Please see the file for additional changes.
  • NEW: Added support for my forked version of another AdMob plugin. See the Readme for details on the plugin.
  • Includes more "Dart like" library. See src/admob.dart for details.

0.0.8+4 #

  • Added "quote" field for Share dialog. Requires version 1.7.2 of the plugin.

0.0.8+3 #

  • Added missing share options for Facebook iOS

0.0.8+2 #

  • Facebook SDK on iOS returns a different structure than Android

0.0.8+1 #

  • Added Facebook library that hides plugin API.
  • Moved Amazon helper library to same file to make things simpler.

0.0.8 #

  • Added support for the Facebook plugin

0.0.7 #

  • Added support for the Statusbar plugin

0.0.6+1 #

  • Return types for non-void methods. Unwraps all "booleanValue" results to straight booleans.

0.0.6 #

  • Added event support for Amazon Ads

0.0.5 #

  • Added missing Device properties

0.0.4 #

  • Added partial support for Amazon Ads plugin (no support for events yet)

0.0.3 #

  • Add support for the In-app Browser plugin

0.0.2 #

  • Added support for Google Analytics and Splashscreen plugins.
  • Updated documentation with more examples

0.0.1 #

  • Initial version
  • Support for AdMob, Device and Store

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  dartins: ^0.2.1+1

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:dartins/dartins.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Feb 13, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.5

Health issues and suggestions

Document public APIs. (-1 points)

474 out of 474 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Format lib/src/admob.dart.

Run dartfmt to format lib/src/admob.dart.

Format lib/src/admob_pro.dart.

Run dartfmt to format lib/src/admob_pro.dart.

Format lib/src/amazon_mobile_ads.dart.

Run dartfmt to format lib/src/amazon_mobile_ads.dart.

Fix additional 11 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/src/app_settings.dart (Run dartfmt to format lib/src/app_settings.dart.)
  • lib/src/av_audio_session.dart (Run dartfmt to format lib/src/av_audio_session.dart.)
  • lib/src/code_push.dart (Run dartfmt to format lib/src/code_push.dart.)
  • lib/src/device.dart (Run dartfmt to format lib/src/device.dart.)
  • lib/src/facebook.dart (Run dartfmt to format lib/src/facebook.dart.)
  • lib/src/google_analytics.dart (Run dartfmt to format lib/src/google_analytics.dart.)
  • lib/src/inapp_browser.dart (Run dartfmt to format lib/src/inapp_browser.dart.)
  • lib/src/network_information.dart (Run dartfmt to format lib/src/network_information.dart.)
  • lib/src/splashscreen.dart (Run dartfmt to format lib/src/splashscreen.dart.)
  • lib/src/statusbar.dart (Run dartfmt to format lib/src/statusbar.dart.)
  • lib/src/store.dart (Run dartfmt to format lib/src/store.dart.)

Maintenance suggestions

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and dartins.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.0.0 <3.0.0
js >=0.6.0 <0.7.0 0.6.1+1
node_interop >=1.0.0 <1.1.0 1.0.3
Dev dependencies
pedantic ^1.8.0+1
test >=0.12.0