Is it possible to use anchor links on a flutter screen to scroll a listview / customscrollview to a certain spot in a page - similar to using anchor links (a href="#" a name="") in HTML?
I've searched for code examples or flutter packages but haven't found anything.
if i'm understaing clearly that you want to jump to certain index
there is a simple method using this package
You can also simply build your own anchor logic with .jumpTo(double (vertical Offset value)) method from ScrollController that you can pass to any sliver widget like CustomScrollView.
Then you can write an extension method on widget that registers Offsets of your anchor objects (have to declare globalKeys on them)
extension GetOffset on Widget {
Offset getOffset() { return this.key.currenContext.findRenderObject().localToGlobal(Offset.zero)}
}
then register the offsets in some shared state to be accesible to the ScrollController and then you can programatically jump to certain positions on the scroll view
Related
Looking at the Flutter Hero Transition, it appears to move the tagged Widgets to an Overlay class that exists in all Navigator Widgets but sits above the main content in the stack.
If this is correct, it allows the Hero to widgets to still respond to the Route scope and its animators but exist above the actual route content. How is this actually done efficiently? Surely this involves taking an entire Widget and storing it in a state for the duration of the animation. That Widget still has to respond to intrinsic responses from its original position such as slivers responding to active scroll actions.
Recreating this could be done with state management but I wondered how the standard hero actually does this. It seems like Widgets are effectively duplicated and then conditionally rendered on the screen defaulting to the overlay during the route animation and swapping out the original widget with an Offstage or similar. Is this how it is done?
The reason for trying to understand it is the need to replicate this behaviour in situations where Navigator is not an effective use case for a transition taking place internally on a page. I built an accordion style navigator but still want a hero transition to take place on the AppBar / NavigationBar. I know that this could be done with Navigator but it doesn't suit the use case. I could also predefine the AppBar content for each internal navigator state of the accordion but that is a lot of additional code.
I have a ScrollablePositionedList and want to do stuff when the next Widget in the List is scrolled to. How can I detect that? I have tried with NotificationListener and ScrollUpdateNotification but only saw the option to use the height of each widget which is flexible and it would be kinda ugly to do it like this. Is there a better way? Like see the pixel height of a widget or is there a function I could use?
You should be able to monitor what items are visible on screen with:
itemPositionsListener.itemPositions.addListener(() => ...);
Then, based on this. you can see whenever there is a change, whenever a new item is scrolled to / appears in the list. then make whatever changes you want
Here is the documentation for more info
I am using scrollable_positioned_list package in my Flutter project but not able to get scroll top position to load and prepend records.
https://pub.dev/packages/scrollable_positioned_list
I'd like to use a scrollbar to display the scroll position for flutter web. ItemScrollController is not ScrollController so I can't wrap my ScrollablePositionedList with a Scrollbar.
I am facing the this issue to load history records. Without getting scroll's top position eg. zero "0" how can I call history records to prepend list? ScrollController has such feature but scrollable_positioned_list widget does not have such feature. any suggestion? Thanks a lot.
I would like to create a scrolling selection widget in Flutter that looks like a horizontal ListView but acts much like a ListWheelScrollView in that it uses FixedExtentScrollController and emits a selection event (callback) for the child scrolled into the center of the list. Especially the list should only allow scrolling by multiples of the size of its children (which are all the same size) and keep one child at the center of the view, even if there are no other children to the right or left.
Is there anything like this out there or do I have to roll my own?
I discovered the Carousel widget from getwidget which can be configured to meet my requirements.
So I am not looking for filters but I am looking for scroll widget. I have tried generating listview items abd getting position of listview to give items ratio but I wasn't able to get any functionality while in certain index position. Any help would be helpfull. Naming of the widget or special widgets that can make me do this etc.
You can use ListView or ListView.builder to do that, but with circle-shaped widgets as the children.
You can check out this tutorial to do the horizontal list. And you can check out this StackOverflow question, to create a circle button. Or instead of a button, you want to use the CircleAvatar (to add an image in it), you can check out this official doc.