Flutterでフローティングアクションボタンについての変更する方法

1: 形状を変更する

FloatingActionButton( 
     shape: BeveledRectangleBorder(
          borderRadius: BorderRadius.zero
     ),
)

2:サイズを変更する

幅と高さは自由に調整できます。

SizedBox( 
    height:100,
    width:100,
    child:FloatingActionButton( 
       child: Icon(Icons.add), 
       onPressed: (){
            print("Button is pressed.");
        },
     ),
),

3:位置を変更する

場所を変更するには、ScaffoldのfloatingActionButtonLocationプロパティを使用します。

Scaffold(
    floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat
)

全部を纏めて、プロジェクトビルド した時

結果

return Scaffold(
        floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
        floatingActionButton: SizedBox(
          height: 100,
          width: 100,
          child: FloatingActionButton(
            child: Icon(Icons.add), 
            shape: BeveledRectangleBorder(borderRadius: BorderRadius.zero),
            onPressed: () {
              print("Button is pressed.");
            },
          ),
        ),
        backgroundColor: Colors.blue[100], 
        appBar: AppBar(
          title: Text("Floating Action Button"), 
          backgroundColor: Colors.redAccent, 
        ),
        body: Center(child: Text("Floating Action Button")));

金曜担当 – Ami



アプリ関連ニュース

お問い合わせはこちら

お問い合わせ・ご相談はお電話、またはお問い合わせフォームよりお受け付けいたしております。

tel. 06-6454-8833(平日 10:00~17:00)

お問い合わせフォーム