init method

void init(
  1. String token,
  2. String uid
)

Initialises BitLabs so that it's ready to use.

This is the essential function. Without it, the library will not function properly. So make sure you call it before using the library's functions.

  • The token is found in your BitLabs Dashboard.
  • The uid should belong to the current user so that you to keep track of which user got what.

Implementation

void init(String token, String uid) {
  _token = token;
  _uid = uid;
  _bitLabsRepository = BitLabsRepository(BitLabsApi(token, uid));

  _bitLabsRepository?.getAppSettings((settings) {
    notifiers.widgetColor.value =
        settings.visual.surveyIconColor.colorsFromCSS().isNotEmpty
            ? settings.visual.surveyIconColor.colorsFromCSS()
            : [Colors.blueAccent, Colors.blueAccent];

    _headerColor = settings.visual.navigationColor.colorsFromCSS().isNotEmpty
        ? settings.visual.navigationColor.colorsFromCSS()
        : [Colors.blueAccent, Colors.blueAccent];

    notifiers.currencyIconURL.value = settings.currency.symbol.isImage
        ? settings.currency.symbol.content
        : '';

    var bonus = settings.currency.bonusPercentage / 100;

    final promotion = settings.promotion;
    if (promotion != null) {
      bonus += promotion.bonusPercentage / 100 +
          (bonus * promotion.bonusPercentage) / 100;
    }

    notifiers.bonusPercentage.value = bonus;
  }, (error) => log(error.toString()));

  _getAdId();
}