appVersion property

Future<String> get appVersion

Implementation

static Future<String> get appVersion async {
  final file = File('$_projectDir/pubspec.yaml');
  if (!file.existsSync()) {
    throw Exception('pubspec.yaml not found');
  }
  final content = await file.readAsString();
  final versionMatch = RegExp(r'version:\s*(.+)').firstMatch(content);
  if (versionMatch == null) {
    throw Exception('version not found in pubspec.yaml');
  }
  return versionMatch.group(1)!.trim();
}