buildButtons method Null safety

List<Widget> buildButtons(
  1. Rect pos
)

Implementation

List<Widget> buildButtons(Rect pos) {
  double y = pos.top;
  final result = List<Widget>.empty(growable: true);
  final double bw = pos.width *
      (width / (numColumns * width + (numColumns - 1) * padRight));
  final double tw = bw * (width + padRight) / width;
  final double bh = bw * height / width;
  // Total height for each button, including any label
  final double th = totalButtonHeight(pos.height, bh);

  // Add the upper yellow labels
  y += addUpperGoldLabels(result, pos, th: th, tw: tw, bh: bh, bw: bw);

  final buttons = controller.getButtonLayout(this, th, bh);
  final List<List<CalculatorButton?>> rc = buttonLayout(buttons);
  for (int i = 0; i < rc.length; i++) {
    double x = pos.left;
    for (int j = 0; j < rc[i].length; j++) {
      final b = rc[i][j];
      if (b != null) {
        result.add(screen.box(Rect.fromLTWH(x, y, bw, bh), b));
      }
      x += tw;
    }
    y += th;
  }
  result.add(screen.box(
      enterPos(pos, th: th, tw: tw, bh: bh, bw: bw), buttons.enter));

  return result;
}