Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to define the starting index of a numbered list #22

Closed
danielporto opened this issue May 11, 2020 · 8 comments
Closed

Allow to define the starting index of a numbered list #22

danielporto opened this issue May 11, 2020 · 8 comments
Labels
enhancement New feature or request

Comments

@danielporto
Copy link

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 danielporto added the enhancement New feature or request label May 11, 2020
@asjqkkkk
Copy link
Owner

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

@asjqkkkk
Copy link
Owner

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

@danielporto
Copy link
Author

danielporto commented May 13, 2020

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.',),);
},)),),)),

@asjqkkkk
Copy link
Owner

Make MarkdownWidget directly wrapped by Expanded

@danielporto
Copy link
Author

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..

@asjqkkkk
Copy link
Owner

could you provider your error logs?

@danielporto
Copy link
Author

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

@asjqkkkk
Copy link
Owner

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😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants