settings static method

Future<void> settings(
  1. BuildContext context
)

Presents the Tiki SDK's pre-built user interface for the settings screen, which allows the user to accept or decline the current offer.

This method creates a new UIHostingController that holds the Tiki SDK's pre-built user interface for the settings screen and presents it with the current root view controller. When the user dismisses the screen, the root view controller is called again to dismiss the created hosting controller.

  • Throws: TikiSdkError if the SDK is not initialized or if no Offer was created.

Implementation

static Future<void> settings(BuildContext context) async {
  _throwIfNotInitialized();
  _throwIfNoOffers();
  String ptr = TikiSdk.instance.offers.values.first.getPtr;
  List<LicenseUsecase> usecases = [];
  List<String> destinations= [];
  TikiSdk.instance.offers.values.first.getUses.forEach( (licenseUse) {
    if(licenseUse.destinations != null){
      destinations.addAll(licenseUse.destinations!);
    }
    usecases.addAll(licenseUse.usecases);
  });
  bool isAccepted = await guard(ptr, usecases, destinations: destinations);
  String terms =
    await DefaultAssetBundle.of(context).loadString(TikiSdk.instance.offers.values.first.getTerms);
  Navigator.of(context)
      .push(MaterialPageRoute(builder: (context) => Settings(isAccepted, terms)));
}