getConfig function
Implementation
SgConfig? getConfig() {
final pubspecFile = File('pubspec.yaml');
if (!pubspecFile.existsSync()) {
ConsoleLogger.error("Sorry, This is not a flutter project");
return null;
}
final pubspec = File('sg_cli.yaml');
try {
if (pubspec.existsSync()) {
final lines = pubspec.readAsLinesSync();
final version = getSingleLineValueFromLines(lines: lines, key: 'version');
final routePaths = getMultilineValueFromLines(lines: lines, key: 'route_paths') ?? <String>[];
if (version != null && routePaths.isNotEmpty) {
final sgConfig = SgConfig(
version: version,
routePaths: routePaths,
);
return sgConfig;
}
}
} catch (e) {
return null;
}
return null;
}