flutterVersion property

String? get flutterVersion

Its Flutter version: from bin/cache/flutter.version.json (newer SDKs), else the old version file; null when neither can be read.

Implementation

String? get flutterVersion {
  final json = File('$root/bin/cache/flutter.version.json');
  try {
    if (json.existsSync()) {
      final v = jsonDecode(json.readAsStringSync());
      final framework = v is Map ? v['frameworkVersion'] : null;
      if (framework is String) return framework;
    }
  } on FormatException {
    // Fall back to the version file.
  } on FileSystemException {
    // Fall back to the version file.
  }
  return _firstWord('$root/version');
}