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

[Question] Custom ScrollController with Toc #27

Closed
the-thirteenth-fox opened this issue May 24, 2020 · 19 comments
Closed

[Question] Custom ScrollController with Toc #27

the-thirteenth-fox opened this issue May 24, 2020 · 19 comments
Labels
question Further information is requested

Comments

@the-thirteenth-fox
Copy link

I need to use my ScrollController and I still want to add Toc support😥. how can I implement this? Preferably with an example.

@asjqkkkk
Copy link
Owner

Toc function is based on ScrollablePositionedList , if you want to use TOC , just use TocController .

but if you want your own ScrollController with TOC, I think it's very hard to achieve.
you can also use MarkdownGenerator to achieve your own MarkdownWidget, so you can do what you want to do

@asjqkkkk asjqkkkk added the question Further information is requested label May 24, 2020
@the-thirteenth-fox
Copy link
Author

What if add the current position checker to the TOC controller?

@asjqkkkk
Copy link
Owner

asjqkkkk commented Jul 1, 2020

What if add the current position checker to the TOC controller?

image

currentToc will be public in v1.2.2, so you can get current position by it

@the-thirteenth-fox
Copy link
Author

I tried to use this construction:

    _tocController = new TocController()
      ..addListener(() {
        _indexToc = _tocController.currentToc.index;
      });

to get the index of current widget, but it is updated when the TOC header changes.

@asjqkkkk
Copy link
Owner

I tried to use this construction:

    _tocController = new TocController()
      ..addListener(() {
        _indexToc = _tocController.currentToc.index;
      });

to get the index of current widget, but it is updated when the TOC header changes.

I think this is unnecessary, because currentToc is always updated by new one

@the-thirteenth-fox
Copy link
Author

the-thirteenth-fox commented Jul 10, 2020

But if I have one header then how to get the index of the current widget?

@asjqkkkk
Copy link
Owner

But if I have one header then how to get the index of the current widget?

What dose one header mean😂

@the-thirteenth-fox
Copy link
Author

image
Like this. I wanna to know index of widget when scrolling down

@asjqkkkk
Copy link
Owner

You can refer to how I did it in the example

image

@the-thirteenth-fox
Copy link
Author

There is no solution to my problem here.

When i leave from page i wanna to save current position. And when i use like this: _tocController.currentToc.index in my example it always 0. The fact is that the text can be large and with a single title. So index can be updated by new one(

@asjqkkkk
Copy link
Owner

the index is followed by Title
image

@asjqkkkk
Copy link
Owner

if there is only one title, the index will only be 0

@the-thirteenth-fox
Copy link
Author

if there is only one title, the index will only be 0

Ow. So it turns out I don't have the ability to get the current position with TOC controller? 0:

@asjqkkkk
Copy link
Owner

I don't understand what you want to get, maybe you mean getTitleIndexWithWidgetIndex in TocController?

@asjqkkkk
Copy link
Owner

asjqkkkk commented Jul 10, 2020

you mean you want to get current index in all widgets or in all Titles?

@the-thirteenth-fox
Copy link
Author

you mean you want to get current index for all widgets or all Titles?

all widgets

@asjqkkkk
Copy link
Owner

you mean you want to get current index for all widgets or all Titles?

all widgets

use this ,you can get current widget's index
image

you can find it in example

@the-thirteenth-fox
Copy link
Author

can u provide example how to use it? I don't understand how to use this.

@asjqkkkk
Copy link
Owner

can u provide example how to use it? I don't understand how to use this.

all samples are there: https://github.com/asjqkkkk/markdown_widget/tree/master/example
this is for users to use markdown_widget

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants