按钮

class MyButtonView extends StatelessWidget {
const MyButtonView({super.key});

@override
Widget build(BuildContext context) {
// TODO: implement build
return ListView(
children: [
Row(
mainAxisAlignment: .spaceAround,
children: [
ElevatedButton(
onPressed: () {
print("一般按钮点击");
},
child: Text("一般按钮"),
), //普通按钮
TextButton(
onPressed: () {
print("文本按钮点击");
},
child: Text("文本按钮"),
),
OutlinedButton(
onPressed: () {
print("带边框按钮点击");
},
child: Text("带边框按钮"),
),
IconButton(
onPressed: () {
print("图标按钮图标按钮点击");
},
icon: Icon(Icons.eighteen_mp_sharp),
),
],
),
SizedBox(height: 10),
Row(
children: [
ElevatedButton.icon(
onPressed: () {},
label: Text("data"),
icon: Icon(Icons.eighteen_mp),
style: ButtonStyle(),
),
TextButton.icon(
onPressed: () {},
label: Text("122"),
icon: Icon(Icons.eighteen_up_rating),
),
OutlinedButton.icon(
onPressed: () {},
label: Text("dsfd"),
icon: Icon(Icons.eighteen_mp_rounded),
),
SizedBox(
width: 120,
height: 80,
child: ElevatedButton.icon(
onPressed: () {},
label: Text("答案呢"),
style: ButtonStyle(
foregroundColor: WidgetStateProperty.all(Colors.pink),
backgroundColor: WidgetStateProperty.all(Colors.orange),
shape: WidgetStateProperty.all(//吧默认圆角去掉
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(0),
),
),
side: WidgetStateProperty.all(BorderSide(width: 5,color: Colors.blue))//边框设置
),
),
),
],
),
],
);
}
}

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容