minSdk function

Future<int?> minSdk({
  1. String prefixPath = '.',
})

Retrieves the minSdk value for the project rooted at prefixPath.

Probes, in order:

  1. App-level gradle file via findAndroidGradleFile (KTS preferred over Groovy). Tries multiple minSdk regex patterns appropriate for the detected DSL.
  2. If a flutter.minSdkVersion indirection is detected, recurses into the Flutter SDK gradle file located via flutter.sdk in local.properties.
  3. Falls back to a flutter.minSdkVersion=... line in local.properties.

Returns null when none of the probes yield a value (caller falls back to constants.androidDefaultAndroidMinSDK).

Known limitations (return null → user must specify min_sdk_android):

  • Version catalogs (libs.versions.toml references like libs.versions.minSdk.get().toInt()).
  • Convention plugin delegation.

Implementation

Future<int?> minSdk({String prefixPath = '.'}) async {
  final detection = await detectMinSdkAndroid(prefixPath: prefixPath);
  return detection.value;
}