どうも、ちょげ(@chogetarou)です。
AlertDialogの下に表示されるボタンを右ではなく、中央に寄せる方法を紹介します。
方法

AlertDialogのボタンを中央に寄せるには、「actions」を使わず、「Rowウェジェット」を使います。
引数「actions」で指定したボタンは、右になるようになっており、変える方法がありません。
なので、代わりにRowウェジェットを使い、中央に寄せれるようにします。
return AlertDialog(
title: Text('Alert'),
content: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text('message'),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
mainAxisSize: MainAxisSize.min,
children: [
TextButton(
onPressed: () {},
child: Text('No'),
),
TextButton(
onPressed: () {},
child: Text('Yes'),
),
],
)
],
),
);
コメント