promotionDialog function Null safety

Future<String?> promotionDialog(
  1. BuildContext context,
  2. ChessboardController controller
)

Show dialog when pawn reaches last square

Implementation

Future<String?> promotionDialog(
    BuildContext context, ChessboardController controller) async {
  return showDialog<String>(
    context: context,
    barrierDismissible: false,
    builder: (BuildContext context) {
      final color = controller.gameLogic.turn;
      return AlertDialog(
        title: Text('Choose promotion'),
        content: Row(
          mainAxisAlignment: MainAxisAlignment.spaceEvenly,
          children: <Widget>[
            InkWell(
              child: color == chessjs.WHITE ? WhiteQueen() : BlackQueen(),
              onTap: () {
                Navigator.of(context).pop("q");
              },
            ),
            InkWell(
              child: color == chessjs.WHITE ? WhiteRook() : BlackRook(),
              onTap: () {
                Navigator.of(context).pop("r");
              },
            ),
            InkWell(
              child: color == chessjs.WHITE ? WhiteBishop() : BlackBishop(),
              onTap: () {
                Navigator.of(context).pop("b");
              },
            ),
            InkWell(
              child: color == chessjs.WHITE ? WhiteKnight() : BlackKnight(),
              onTap: () {
                Navigator.of(context).pop("n");
              },
            ),
          ],
        ),
      );
    },
  ).then((value) {
    return value;
  });
}