Description
As of now, some positions are impossible, both for the constructor and for methods that accept alignment
.
Examples below given for a vertical non-reversed list:
- It's impossible to align the center of the item to the center of the Viewport.
- It's impossible to align the bottom of the item to the center of the Viewport.
- It's impossible to align the bottom of the item to the bottom of the Viewport.
The only precise positioning here is aligning the top of the item to the top of the Viewport, or putting the top of the item right below the Viewport.
I'd say, as it is, alignment
is quite useless.
1) When using a single alignment like this its much better to follow Flutter's Align
widget standard of always keeping the item inside of the Viewport. In the standard, 0.0
means the top of the item would be at the top of the screen, while 1.0
means the bottom of the item would be at the bottom of the screen.
2) Another (in my opinion better) possibility is having two alignment proprieties, one that refers to the Viewport, and another that refers to the item:
itemScrollController.jumpTo(index: 10, viewportAlignment: 0.0, itemAlignment: 0.5);
In this example, the center of the item (0.5
) would be aligned to the top of the screen (0.0
).
3) Pixel positions should be possible too:
itemScrollController.jumpTo(
index: 10,
viewportAlignment: 0.0,
itemAlignment: 0.0,
pixelDistance: 25.0);
In this example, the top of the item would be aligned to 25.0
pixels to the top of the screen (for vertical non-reversed lists).