markdown_widget icon indicating copy to clipboard operation
markdown_widget copied to clipboard

Allow to define the starting index of a numbered list

Open danielporto opened this issue 4 years ago • 8 comments

Is your feature request related to a problem? Please describe. Currently a numbered list starts with 0 and I cannot figure out a way to change it.

Describe the solution you'd like I would like it to start with 1. However imagine a list with a text in between and the the continuation of the list, perhaps one want to start the list with a different index. It would be nice to be able to control the starting index.

Describe alternatives you've considered Only hardcoding and the list.

danielporto avatar May 11 '20 17:05 danielporto

It's not hard, I will add initialScrollIndex to MarkdownWidget later

asjqkkkk avatar May 12 '20 01:05 asjqkkkk

you can update to v1.1.9, use initialIndex to define the starting index of a numbered list

asjqkkkk avatar May 13 '20 00:05 asjqkkkk

I couldn't make it work. Please check if that's the right way:

Expanded( child: Padding( padding: EdgeInsets.all(20), child: MarkdownWidget( data: termsOfUse, controller: TocController(initialIndex: 1), styleConfig: StyleConfig( // fix breaklines after bold pConfig: PConfig(selectable: false, ), // fix list index alignment olConfig: OlConfig(indexWidget: (deep, index) { return Container(margin: EdgeInsets.only(left: 5, right: 5), child: Text(index < 10 ? ' $index.':'$index.',),); },)),),)),

danielporto avatar May 13 '20 12:05 danielporto

Make MarkdownWidget directly wrapped by Expanded

asjqkkkk avatar May 13 '20 13:05 asjqkkkk

I've tried all combinations, remove the padding, wrapping with a container, nothing works. the only hack I manage to make it work was adding an index++; right after OlConfig(indexWidget: (deep, index) { It's an ugly hack though..

danielporto avatar May 13 '20 20:05 danielporto

could you provider your error logs?

asjqkkkk avatar May 14 '20 01:05 asjqkkkk

Unfortunately there is no error anywhere. it silently ignores the TOCController(initialIndex: 1)

danielporto avatar May 26 '20 19:05 danielporto

Unfortunately there is no error anywhere. it silently ignores the TOCController(initialIndex: 1)

In my test, it's ok

  final TocController controller = TocController(initialIndex: 5);

demo

demo

can you provider more information😅

asjqkkkk avatar May 27 '20 02:05 asjqkkkk