getFileContent static method
Reads and returns the content of the pubspec.yaml file. @returns {PubspecContentModel?} The file content, or null if not found.
Implementation
static PubspecContentModel? getFileContent(String filePath) {
final file = File(filePath);
if (!file.existsSync()) {
stderr.writeln('Error: $filePath not found in the current directory.');
return null;
}
try {
return PubspecContentModel(
path: filePath,
content: file.readAsStringSync(),
);
} on FileSystemException catch (e) {
stderr.writeln('Error reading $filePath: ${e.message}');
return null;
}
}