Flutter Containerを使ってアイコンのの形を指定するサンプル

環境
Windows11 pro 64bit
Flutter 3.3.7

構文
Container(
decoration: BoxDecoration( //Containerの引数「decoration」にBoxDecorationを指定
shape: BoxShape.circle, //引数「shape」に形を指定
Containerを使ってアイコン(Icon)の形を指定します。

使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.green,
),
child: Icon(
Icons.account_balance,
color: Colors.gray,
size: 80,
),
padding: EdgeInsets.all(8),
)
Container( decoration: BoxDecoration( shape: BoxShape.circle, color: Colors.green, ), child: Icon( Icons.account_balance, color: Colors.gray, size: 80, ), padding: EdgeInsets.all(8), )
 Container(
  decoration: BoxDecoration(
    shape: BoxShape.circle, 
    color: Colors.green,
  ),
  child: Icon(
    Icons.account_balance,
    color: Colors.gray,
    size: 80,
  ),
  padding: EdgeInsets.all(8),
)

 

Flutter

Posted by arkgame