build method

  1. @override
Widget build(
  1. BuildContext context,
  2. SwiperPluginConfig config
)
override

Implementation

@override
Widget build(BuildContext context, SwiperPluginConfig config) {
  ThemeData themeData = Theme.of(context);
  Color activeColor = this.activeColor ?? themeData.primaryColor;
  Color color = this.color ?? themeData.scaffoldBackgroundColor;

  List<Widget> list = [];

  if (config.itemCount > 20) {
    print(
        "The itemCount is too big, we suggest use FractionPaginationBuilder instead of DotSwiperPaginationBuilder in this sitituation");
  }

  int itemCount = config.itemCount;
  int activeIndex = config.activeIndex;

  for (int i = 0; i < itemCount; ++i) {
    bool active = i == activeIndex;
    Size size = active ? this.activeSize : this.size;
    list.add(SizedBox(
      width: size.width,
      height: size.height,
      child: Container(
        color: active ? activeColor : color,
        key: Key("pagination_$i"),
        margin: EdgeInsets.all(space),
      ),
    ));
  }

  if (config.scrollDirection == Axis.vertical) {
    return new Column(
      key: key,
      mainAxisSize: MainAxisSize.min,
      children: list,
    );
  } else {
    return new Row(
      key: key,
      mainAxisSize: MainAxisSize.min,
      children: list,
    );
  }
}