getFormattedCode method

String getFormattedCode()

Returns the code wrapped in a markdown fenced code block with the selected language tag. Returns empty string if editor is empty.

Implementation

String getFormattedCode() {
  final code = _codeController.text;
  if (code.trim().isEmpty) return '';
  final tag = _fenceTags[_selectedLanguage] ?? '';
  return '```$tag\n$code\n```';
}