[Mobile] wrong ordered list numeration with TextField
My issue is about [Mobile]
I created a form using flutter-quill: ^7.2.0, but I am experiencing an issue when I use the ordered list.
When I click the content, it updates the ordered list numeration randomly.
My code looks like
import 'package:flutter/material.dart';
import 'package:flutter_quill/flutter_quill.dart' hide Text;
class QuillView extends StatefulWidget {
final List<dynamic> jsonData;
final TextStyle? textStyle;
const QuillView({
super.key,
required this.jsonData,
this.textStyle,
});
@override
State<StatefulWidget> createState() => QuillViewState();
}
class QuillViewState extends State<QuillView> {
final FocusNode _focusNode = FocusNode();
late QuillController _controller = QuillController.basic();
void _loadDocument() {
try {
_controller.dispose();
_controller = QuillController(
document: Document.fromJson(widget.jsonData),
selection: const TextSelection.collapsed(offset: 0),
);
} catch (e) {
final doc = Document()..insert(0, '');
_controller = QuillController(
document: doc,
selection: const TextSelection.collapsed(offset: 0),
);
}
setState(() {});
}
@override
void initState() {
super.initState();
_loadDocument();
}
@override
void didUpdateWidget(QuillView oldWidget) {
super.didUpdateWidget(oldWidget);
if (oldWidget.jsonData != widget.jsonData) {
_loadDocument();
}
}
@override
void dispose() {
super.dispose();
_controller.dispose();
}
@override
Widget build(BuildContext context) {
return DefaultTextStyle.merge(
style: widget.textStyle,
child: QuillEditor(
controller: _controller,
scrollController: ScrollController(),
scrollable: true,
focusNode: _focusNode,
autoFocus: false,
readOnly: true,
expands: false,
showCursor: false,
padding: EdgeInsets.zero,
),
);
}
}
Any solution please?
I have similar , need fix. And in another case there was a numbering of empty rows: after clicking to add a new line, the numbers were simply incremented. And after 99, it wrote 10 without displaying the third character
@EgorK0rshun As a temporary solution, you can update the code like the below:
Code:
Result:
@antrusha0223 I can't reproduce your error
@EgorK0rshun Fixed on #1373