flutter-quill icon indicating copy to clipboard operation
flutter-quill copied to clipboard

[Mobile] wrong ordered list numeration with TextField

Open antrusha0223 opened this issue 2 years ago • 4 comments

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.

image

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?

antrusha0223 avatar May 31 '23 04:05 antrusha0223

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 avatar Jun 05 '23 17:06 EgorK0rshun

@EgorK0rshun As a temporary solution, you can update the code like the below:

Code: image

Result: image

hoangsang17th avatar Jun 30 '23 10:06 hoangsang17th

@antrusha0223 I can't reproduce your error

hoangsang17th avatar Jun 30 '23 10:06 hoangsang17th

@EgorK0rshun Fixed on #1373

hoangsang17th avatar Aug 29 '23 09:08 hoangsang17th