queryPassage function

Future<PassageQuery> queryPassage(
  1. String queryReference,
  2. {String version,
  3. BibleProvider provider,
  4. Map<String, String> parameters,
  5. dynamic useParser = true,
  6. String providerName,
  7. String key}
)

Query a provider for a bible passage.

Bible will use the recommended/default query provider if the provider is not specified in the optional parameter. If an adequet provider is not found to supply the version request or if the reference is invalid, a null value will be returned.

Implementation

Future<PassageQuery> queryPassage(String queryReference,
    {String version,
    BibleProvider provider,
    Map<String, String> parameters,
    useParser = true,
    String providerName,
    String key}) {
  if (provider == null && providerName != null) {
    provider = getProvider(providerName);
  }
  if (version != null && provider == null) {
    provider ??= getDefaultProvider(version);
  } else if (provider == null) {
    provider = getProvider('getbible');
  }

  if (provider == null) {
    return null;
  }
  BibleReference ref;
  if (useParser) {
    ref = parseReference(queryReference);
  }
  // Tries to parse the reference, if unable just use the original query.
  if (ref == null || !ref.isValid) {
    ref = Reference(queryReference);
  }

  key ??= getKey(provider.name);
  if (provider.requiresKey && key == null) {
    return null;
  }

  parameters ??= {};
  return provider.getPassage(ref,
      parameters: parameters, key: key, version: version);
}