Milad-Akarie / smooth_page_indicator

Flutter Smooth PageView indicators
MIT License
1.22k stars 147 forks source link

Active dot not preserving state #8

Closed neofactoris3 closed 1 year ago

neofactoris3 commented 4 years ago

When moved to a different tab and returned, the active dot moves to the first position but on scroll change, it moves to the correct position. How to ensure that the active dot state is preserved when moving to different tabs etc?

Milad-Akarie commented 4 years ago

@neofactoris3 can you please share your setup so I can reproduce this?

neofactoris3 commented 4 years ago

https://pastebin.com/HbeFft8g

Milad-Akarie commented 4 years ago

@neofactoris3 I think your link is broken?

neofactoris3 commented 4 years ago

https://pastebin.com/HbeFft8g

Milad-Akarie commented 4 years ago

Where are you initializing your PageController?

neofactoris3 commented 4 years ago

class _GetAppState extends State<GetApp> { PageController _controller = PageController(initialPage: 0); }

neofactoris3 commented 4 years ago

Any updates?

neofactoris3 commented 4 years ago

I have tried to set a key as well but it does no work...

new SmoothPageIndicator( key: PageStorageKey('smoothPageIndicatorKey'), controller: _controller, count: snapshot.data['unreadNews'] .toList() .length, effect: SlideEffect( spacing: 4.0, radius: 4.0, dotWidth: 12.0, dotHeight: 6.0, paintStyle: PaintingStyle.fill, dotColor: Colors.grey .withOpacity(0.3), activeDotColor: Color( 0xff449e47)), ),

Any help is much appreciated...

Thank you!

Milad-Akarie commented 4 years ago

@neofactoris3 Sorry for keeping you waiting, I was actually really busy lately. I'll look into it today.

you're using TabView to handle your tabs right?

Milad-Akarie commented 4 years ago

@neofactoris3 I failed to reproduce the error. could you create a gist of a working example?

Milad-Akarie commented 4 years ago

@neofactoris3 This might help https://github.com/Milad-Akarie/auto_route_library/issues/81#issuecomment-620580590

neofactoris3 commented 4 years ago

I had tried it earlier... It was not working...

In fact, the page viewer does not lose the state, when I navigate back to the parent page, I can see the pageviewer retains the page I left it but smooth_page_indicator active dot is at the first position, however, if I slide the page, the active dot goes back to the exact location.

Milad-Akarie commented 4 years ago

smooth_page_indicator is sharing the same state with the pageView so this's really confusing lol

neofactoris3 commented 4 years ago

This is what happens... Video demonstration

Milad-Akarie commented 4 years ago

@neofactoris3 I see.. What are you using to manage your tabs? TabView?

neofactoris3 commented 4 years ago

it's fancy bottom navigation

Walker-ZHAO commented 2 years ago

@neofactoris3 you can use FutureBuilder to wrap SmoothPageIndicator. Ref: https://stackoverflow.com/questions/61058420/flutter-pagecontroller-page-cannot-be-accessed-before-a-pageview-is-built-with

github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions