Flutter Container内の位置を中央寄せにするサンプル

環境
Windows11 pro 64bit
Flutter 3.3.7

構文
Container(
alignment: Alignment.center,
),
Containerを中央寄せにするには、引数「alignment」に「Alignment.center」を指定します。

使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
Container(
alignment: Alignment.center,
height: 200,
width: 200,
color: Colors.red,
child: Text('test'),
),
Container( alignment: Alignment.center, height: 200, width: 200, color: Colors.red, child: Text('test'), ),
Container(
  alignment: Alignment.center,
  height: 200,
  width: 200,
  color: Colors.red,
  child: Text('test'),
),

 

 

Flutter

Posted by arkgame