Commit 606887a1 authored by Hans Muller's avatar Hans Muller

Merge pull request #1127 from HansMuller/fix_tabs

Fix tab fling scrolling when the last tab is selected
parents 39ad22c8 5966f676
...@@ -806,7 +806,7 @@ class _TabBarViewState<T> extends PageableListState<TabBarView<T>> implements Ta ...@@ -806,7 +806,7 @@ class _TabBarViewState<T> extends PageableListState<TabBarView<T>> implements Ta
_selection = selection; _selection = selection;
if (_selection != null) { if (_selection != null) {
_selection.registerPerformanceListener(this); _selection.registerPerformanceListener(this);
_initItemIndicesAndScrollPosition(); _initItemsAndScrollOffset();
} }
} }
...@@ -831,18 +831,18 @@ class _TabBarViewState<T> extends PageableListState<TabBarView<T>> implements Ta ...@@ -831,18 +831,18 @@ class _TabBarViewState<T> extends PageableListState<TabBarView<T>> implements Ta
_items.add(widgets[third]); _items.add(widgets[third]);
} }
void _initItemIndicesAndScrollPosition() { void _initItemsAndScrollOffset() {
assert(_selection != null); assert(_selection != null);
final int selectedIndex = _selection.index; final int selectedIndex = _selection.index;
if (selectedIndex == 0) { if (selectedIndex == 0) {
_updateItems(0, 1); _updateItems(0, 1);
scrollTo(0.0); scrollTo(scrollBehavior.updateExtents(contentExtent: 2.0, containerExtent: 1.0, scrollOffset: 0.0));
} else if (selectedIndex == _tabCount - 1) { } else if (selectedIndex == _tabCount - 1) {
_updateItems(selectedIndex - 1, selectedIndex); _updateItems(selectedIndex - 1, selectedIndex);
scrollTo(1.0); scrollTo(scrollBehavior.updateExtents(contentExtent: 1.0, containerExtent: 1.0, scrollOffset: 1.0));
} else { } else {
_updateItems(selectedIndex - 1, selectedIndex, selectedIndex + 1); _updateItems(selectedIndex - 1, selectedIndex, selectedIndex + 1);
scrollTo(1.0); scrollTo(scrollBehavior.updateExtents(contentExtent: 3.0, containerExtent: 1.0, scrollOffset: 1.0));
} }
} }
...@@ -857,7 +857,7 @@ class _TabBarViewState<T> extends PageableListState<TabBarView<T>> implements Ta ...@@ -857,7 +857,7 @@ class _TabBarViewState<T> extends PageableListState<TabBarView<T>> implements Ta
final Performance performance = _selection.performance; final Performance performance = _selection.performance;
if (performance.status == PerformanceStatus.completed) { if (performance.status == PerformanceStatus.completed) {
_initItemIndicesAndScrollPosition(); _initItemsAndScrollOffset();
return; return;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment