checkAppInstalled method

Future<void> checkAppInstalled({
  1. required List<String> features,
  2. bool throwError = true,
  3. String appName = 'renovation_core',
})

Silent method throwing an error AppNotInstalled if appName is not installed in the backend and throwError is set.

To be used in controller's methods where the endpoints are defined in a custom app.

When throwError is set to false, the method will just wait for the appVersions to load.

Specify the features to be used for the app.

appName defaults to 'renovation_core' throwError defaults to true

Implementation

Future<void> checkAppInstalled(
    {required List<String> features,
    bool throwError = true,
    String appName = 'renovation_core'}) async {
  while (!appVersionsLoaded) {
    await Future<dynamic>.delayed(Duration(milliseconds: 100));
  }

  if (!_appVersions.containsKey(appName) && throwError) {
    throw AppNotInstalled(appName, features);
  }
}