聊聊 Flutter 2021 中的按鈕
在本文中,我們將介紹令人驚嘆的 Flutter 按鈕,它們可以幫助所有初學者或?qū)I(yè)人士為現(xiàn)代應用程序設計漂亮的 UI。
首先讓我告訴你關于 Flutter 中按鈕的一件重要事情,在flutter最新版本中以下Buttons在fluter中被廢棄了:
廢棄的 | 推薦的替代 |
---|---|
RaisedButton | ElevatedButton |
OutlineButton | OutlinedButton |
FlatButton | TextButton |
那么讓我們來探索一下 Flutter 中的按鈕。
Elevated Button
StadiumBorder
- ElevatedButton(
- onPressed: (){},
- child: Text('Button'),
- style: ElevatedButton.styleFrom(
- shadowColor: Colors.green,
- shape: StadiumBorder(),
- padding: EdgeInsets.symmetric(horizontal: 35,vertical: 20)),
- )
RoundedRectangleBorder
- ElevatedButton(
- onPressed: (){},
- child: Text('Button'),
- style: ElevatedButton.styleFrom(
- shadowColor: Colors.green,
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(12),
- ),
- ),
- ),
CircleBorder
- ElevatedButton(
- onPressed: () {},
- child: Text('Button'),
- style: ElevatedButton.styleFrom(
- shape: CircleBorder(),
- padding: EdgeInsets.all(24),
- ),
- )
BeveledRectangleBorder
- ElevatedButton(
- onPressed: () {},
- child: Text('Button'),
- style: ElevatedButton.styleFrom(
- shape: BeveledRectangleBorder(
- borderRadius: BorderRadius.circular(12)
- ),
- ),
- )
Outlined Button
StadiumBorder
- OutlinedButton(
- onPressed: () {},
- child: Text('Button'),
- style: OutlinedButton.styleFrom(
- shape: StadiumBorder(),
- ),
- )
RoundedRectangleBorder
- OutlinedButton(
- onPressed: () {},
- child: Text('Button'),
- style: OutlinedButton.styleFrom(
- shape: BeveledRectangleBorder(
- borderRadius: BorderRadius.circular(12),
- ),
- ),
- )
CircleBorder
- OutlinedButton(
- onPressed: () {},
- child: Text('Button'),
- style: OutlinedButton.styleFrom(
- shape: CircleBorder(),
- padding: EdgeInsets.all(24),
- ),
- )
BeveledRectangleBorder
- OutlinedButton(
- onPressed: () {},
- child: Text('Button'),
- style: OutlinedButton.styleFrom(
- shape: BeveledRectangleBorder(
- borderRadius: BorderRadius.circular(12),
- ),
- ),
- )
原文:https://medium.com/@waseemakram.jpb/button-cheat-sheet-in-flutter-2021-1db38501d5f2