I want to if QuillController().document.isEmpty() is false, button is active. otherwise, true make button is inactive. this code make user can not write content in quillEditor. I think setState((){}) is problem. because, I delete setState, user can write content, but button is not change by QuillController().document.isEmpty()
@override
void initState(){
super.initState();
_contentEditingController = QuillController(
document: Document(),
selection: const TextSelection.collapsed(offset: 0),
onSelectionChanged: (data) {
if (_titleEditingController.text.isEmpty ||
_contentEditingController.document.isEmpty()) {
_isButtonActive = false;
} else {
_isButtonActive = true;
}
setState(() {});
});}
or
Widget _contentContainer() {
_contentEditingController.document.changes.listen((event) {
if (_titleEditingController.text.isEmpty ||
_contentEditingController.document.isEmpty()) {
setState(() => _isButtonActive = false);
} else {
setState(() => _isButtonActive = true);
}
});
return Expanded(
child: Scrollbar(
controller: _scrollController,
child: QuillEditor(
controller: _contentEditingController,
scrollController: _scrollController,
scrollable: true,
expands: true,
readOnly: false,
focusNode: FocusNode(),
autoFocus: false,
padding: EdgeInsets.symmetric(horizontal: 15.0.w, vertical: 10.0.h),
placeholder: "내용을 입력해주세요",
),
));
}