build method
Implementation
@override
Widget build(BuildContext context, SwiperPluginConfig config) {
if (config.itemCount > 20) {
print('warning: The itemCount is too big, '
'we suggest use TDFractionPaginationBuilder');
}
var activeColor = this.activeColor ??
(config.outer
? TDTheme.of(context).brandNormalColor
: TDTheme.of(context).whiteColor1);
var color = this.color ??
(config.outer
? TDTheme.of(context).grayColor3
: TDTheme.of(context).whiteColor1.withOpacity(0.55));
if (config.indicatorLayout != PageIndicatorLayout.NONE &&
config.layout == SwiperLayout.DEFAULT) {
return PageIndicator(
count: config.itemCount,
controller: config.pageController,
layout: config.indicatorLayout,
size: size,
activeColor: activeColor,
color: color,
space: space,
);
}
var list = <Widget>[];
var itemCount = config.itemCount;
var activeIndex = config.activeIndex;
for (var i = 0; i < itemCount; ++i) {
var active = i == activeIndex;
var isActiviRectangle =
roundedRectangleWidth != null && roundedRectangleWidth! > 0 && active;
list.add(Container(
key: Key('pagination_$i'),
margin: EdgeInsets.all(space),
child: AnimatedContainer(
duration:
Duration(milliseconds: animationDuration ?? _kAminatedDuration),
width: isActiviRectangle
? roundedRectangleWidth
: (active ? activeSize : size),
height: active ? activeSize : size,
decoration: BoxDecoration(
color: active ? activeColor : color,
borderRadius: BorderRadius.circular(activeSize / 2)),
),
));
}
if (config.scrollDirection == Axis.vertical) {
return Column(
key: key,
mainAxisSize: MainAxisSize.min,
children: list,
);
} else {
return Row(
key: key,
mainAxisSize: MainAxisSize.min,
children: list,
);
}
}