createFileFromStringSafe function

Future<void> createFileFromStringSafe(
  1. String filePath,
  2. String content
)

Implementation

Future<void> createFileFromStringSafe(String filePath, String content) async {
  try {
    final file = File(filePath);

    // Create the file and write content
    await file.writeAsString(content);

    print('File created at ${file.path}');
  } catch (e) {
    print('Error creating file: $e');
  }
}