convertTextToQuill static method
QuillController
convertTextToQuill(
- String text
)
Implementation
static QuillController convertTextToQuill(String text) {
if (text.isNotEmpty) {
if (text.contains("insert")) {
return QuillController(
document: Document.fromJson(jsonDecode(text)),
selection: const TextSelection.collapsed(offset: 0),
);
} else {
return QuillController(
document: Document.fromJson([
{'insert': '$text\n'}
]),
selection: const TextSelection.collapsed(offset: 0));
}
} else {
return QuillController(
document: Document(),
selection: const TextSelection.collapsed(offset: 0));
}
}