Flutter TabController,TabBar,TabBarView

TabController:控制器

void _changeIndex(int value, { Duration duration, Curve curve }) {

assert(value !=null);

assert(value >=0 && (value

assert(duration !=null || curve ==null);

assert(_indexIsChangingCount >=0);

if (value ==_index ||length <2)

return;

_previousIndex =index;

_index = value;

if (duration !=null) {

_indexIsChangingCount +=1;

notifyListeners();// Because the value of indexIsChanging may have changed.

    _animationController

      .animateTo(_index.toDouble(), duration: duration, curve: curve)

.whenCompleteOrCancel(() {

_indexIsChangingCount -=1;

notifyListeners();

});

}else {

_indexIsChangingCount +=1;

_animationController.value =_index.toDouble();

_indexIsChangingCount -=1;

notifyListeners();

}

}

TabBar:

const TabBar({

Key key,

@required this.tabs,//子标签

this.controller,//控制器

this.isScrollable =false,//能否滑动

this.indicatorColor,//指示器颜色

this.indicatorWeight =2.0,//指示器高度

this.indicatorPadding = EdgeInsets.zero,//指示器padding

this.indicator,//指示器的形状

this.indicatorSize,//指示器宽度

this.labelColor,//选中颜色

this.labelStyle,//选中样式

this.labelPadding,//标签padding

this.unselectedLabelColor,//未选中颜色

this.unselectedLabelStyle,//未选中样式

this.dragStartBehavior = DragStartBehavior.start,//确定处理拖动开始行为的方式

this.onTap,//点击事件

})

TabBarView:

const TabBarView({

Key key,

@required this.children,//子widget

this.controller,//控制器

this.physics,//可以设置NeverScrollableScrollPhysics()禁止滑动,

this.dragStartBehavior = DragStartBehavior.start,//确定处理拖动开始行为的方式

})

你可能感兴趣的:(Flutter TabController,TabBar,TabBarView)