axisXLabels method

Widget axisXLabels(
  1. double gh,
  2. double gw,
  3. BuildContext context,
  4. List<Point> points,
)

Implementation

Widget axisXLabels(double gh, double gw, BuildContext context, List<Point> points) {
  return Padding(
    padding: const EdgeInsets.only(left: 8),
    child: SizedBox(
      height: gh,
      width: gw,
      child: ListView.builder(
          physics: const NeverScrollableScrollPhysics(),
          shrinkWrap: true,
          scrollDirection: Axis.horizontal,
          itemCount: points.length,
          itemBuilder: (_, i) {
            return Row(
              children: [
                SizedBox(
                  width: gw * 0.1,
                  height: gh * 0.02,
                  child: Align(
                    alignment: Alignment.center,
                    child: Text(
                      points[i].x.toString().split('.')[0],
                      style: const TextStyle(
                        color: Colors.black,
                        fontSize: 10,
                      ),
                    ),
                  ),
                ),
                if (i == 0)
                  SizedBox(
                    width: gw * 0.8 / (points.length - 1) - gw * 0.1,
                  )
                else if (i == points.length - 2 && points.length > 3)
                  SizedBox(
                    width: gw * 0.8 / (points.length - 1) - gw * 0.1,
                  )
                else if (i == points.length - 1)
                    Container()
                  else
                    SizedBox(
                      width: gw * 0.9 / (points.length - 1) - gw * 0.1,
                    )
              ],
            );
          }),
    ),
  );
}