loadFromPath static method
Loads the Flutter project from the given path
.
The project is loaded by locating the FVM config file and the pubspec.yaml file.
Implementation
static Project loadFromPath(String path) {
final configFile = _fvmConfigPath(path);
final legacyConfigFile = _legacyFvmConfigPath(path);
ProjectConfig? config = ProjectConfig.loadFromPath(configFile);
// Used for migration of config files
final legacyConfig = ProjectConfig.loadFromPath(legacyConfigFile);
if (legacyConfig != null && config != null) {
final legacyVersion = legacyConfig.flutter;
final version = config.flutter;
if (legacyVersion != version) {
logger
..warn(
'Found fvm_config.json with SDK version different than .fvmrc\n'
'fvm_config.json is deprecated and will be removed in future versions.\n'
'Please do not modify this file manually.',
)
..spacer
..warn('Ignoring fvm_config.json');
}
}
if (config == null && legacyConfig != null) {
legacyConfig.save(configFile);
}
config = ProjectConfig.loadFromPath(configFile);
final pubspecFile = File(join(path, 'pubspec.yaml'));
final pubspec = pubspecFile.existsSync()
? PubSpec.fromYamlString(pubspecFile.readAsStringSync())
: null;
return Project(config: config, path: path, pubspec: pubspec);
}