getStyle method

dynamic getStyle(
  1. int index,
  2. int currentIndex, {
  3. String? label,
  4. Icon? icon,
  5. double labelWidth = 150,
})

Implementation

getStyle(int index, int currentIndex,
    {String? label, Icon? icon, double labelWidth = 150}) {
  return Container(
    width: labelWidth,
    decoration: BoxDecoration(
      color: currentIndex == index ? Colors.white : Colors.transparent,
      borderRadius: BorderRadius.circular(50),
      border: Border.all(
        color: currentIndex == index ? Colors.white : Colors.white,
        width: currentIndex == index ? 0 : 2,
      ),
    ),
    child: Row(
      children: <Widget>[
        Padding(
          padding: EdgeInsets.only(
            top: currentIndex == index ? 3 : 2,
            bottom: currentIndex == index ? 2 : 2.5,
            left: currentIndex == index ? 3 : 0,
          ),
          child: CircleAvatar(
            child: Text(
              (index + 1).toString(),
              style: TextStyle(
                  fontSize: 20,
                  fontWeight: FontWeight.bold,
                  color: currentIndex == index ? Colors.white : Colors.blue),
            ),
            radius: 18,
            backgroundColor:
                currentIndex == index ? Colors.blue : Colors.white,
            foregroundColor:
                currentIndex == index ? Colors.white : Colors.blue,
          ),
        ),
        Expanded(
          child: Padding(
            padding: const EdgeInsets.only(top: 2.0),
            child: Align(
              alignment: Alignment.center,
              child: Text(
                label!,
                style: TextStyle(
                    fontWeight: FontWeight.bold,
                    fontSize: 16,
                    color:
                        currentIndex == index ? Colors.blue : Colors.white),
              ),
            ),
          ),
        ),
      ],
    ),
  );
}