I used flutter_quill: ^6.1.7 to create such a design
But I can't send the html text to the api
Such as <h1 > Title </h1>
CodePudding user response:
You can use delta_markdown and markdown package for this:
String quillDeltaToHtml(Delta delta) {
final markdown = deltaToMarkdown(delta);
final html = markdownToHtml(markdown);
return html;
}
CodePudding user response:
First, install the delta_markdown
and markdown
packages.
Then, try the following code:
import 'package:delta_markdown/delta_markdown.dart';
import 'package:markdown/markdown.dart' hide Text;
final QuillController quillController = QuillController.basic();
QuillToolbar.basic(
controller: quillController,
…
),
final Delta delta = quillController.document.toDelta();
final String convertedValue = jsonEncode(delta.toJson());
final String markdown = deltaToMarkdown(convertedValue);
final String html = markdownToHtml(markdown);