getPackage method

  1. @override
Future<Either<ApplicationException, ApplicationModel>> getPackage(
  1. GetApplicationModel getApplication
)
override

Get application by packageName and if does application exists returns ApplicationModel, does not return an ApplicationException

Implementation

@override
Future<Either<ApplicationException, ApplicationModel>> getPackage(
  GetApplicationModel getApplication,
) async {
  try {
    final application = await channel.invokeMethod(
      Channels.getApplication.value,
      getApplication.toJson(),
    );

    return right(ApplicationModel.fromJson(application));
  } on PlatformException catch (error) {
    switch (error.code) {
      case ApplicationPackageNameDoesNotBeEmptyException.code:
        return left(ApplicationPackageNameDoesNotBeEmptyException(error));
      case ApplicationNotFoundException.code:
        return left(ApplicationNotFoundException(error));
      default:
        return left(GetApplicationException(error));
    }
  }
}