buildItems method

List<Widget> buildItems()

Implementation

List<Widget> buildItems() {
  var items = <Widget>[];

  var length = widget.items.length;
  for (int i = 0; i < length; i++) {
    items.add(GestureDetector(
      behavior: HitTestBehavior.opaque,
      onTapDown: (TapDownDetails details) {
        if (_selectedItem == widget.items[i]) {
          return;
        }
        _selectedItem = widget.items[i];
        if (widget.onItemSelected != null) {
          widget.onItemSelected!(_selectedItem!);
        }
        _animationController
            .animateTo(1 / widget.items.length * i)
            .whenCompleteOrCancel(() {
          _bounceController.forward().whenCompleteOrCancel(() {
            _bounceController.reverse();
          });
        });
      },
      child: Container(
        width: 300,
        margin: const EdgeInsets.all(0),
        padding: const EdgeInsets.only(left: 3),
        alignment: const Alignment(-1, 0),
        height: itemHeight,
        child: Text(
          widget.items[i],
          textAlign: TextAlign.left,
          style: TextStyle(
            fontSize: 20,
            color: widget.textColor,
            fontFamily: defaultFontFamily,
          ),
        ),
      ),
    ));
  }
  if (_selectedItem == null && widget.items.isNotEmpty) {
    _selectItem(widget.items[0]);
  }
  return items;
}