Correct the TabBarView swipe selection change animation
The TabBarSelection change animation needs to start where the fling's drag gesture ended rather than from zero. The intial vlaue of progress for the TabBarSelection's performance is now converted from the range used during an interactive drag, to the range used when animating from the previously selected tab to the new one. TabBarSelection now requires a maxIndex parameter.
This commit is contained in:
@@ -6,8 +6,8 @@ import 'package:flutter/material.dart';
|
||||
|
||||
import 'widget_demo.dart';
|
||||
|
||||
final TabBarSelection _selection = new TabBarSelection();
|
||||
final List<String> _iconNames = <String>["event", "home", "android", "alarm", "face", "language"];
|
||||
final TabBarSelection _selection = new TabBarSelection(maxIndex: _iconNames.length - 1);
|
||||
|
||||
Widget buildTabBar(_) {
|
||||
return new TabBar(
|
||||
|
||||
@@ -30,7 +30,7 @@ class StockHomeState extends State<StockHome> {
|
||||
super.initState();
|
||||
_tabBarSelection = PageStorage.of(context)?.readState(context);
|
||||
if (_tabBarSelection == null) {
|
||||
_tabBarSelection = new TabBarSelection();
|
||||
_tabBarSelection = new TabBarSelection(maxIndex: 1);
|
||||
PageStorage.of(context)?.writeState(context, _tabBarSelection);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user