【发布时间】:2022-08-19 00:56:44
【问题描述】:
我的小部件中连续有 4 个 ElevatedButtons。如果其中一个被按下,将根据按钮显示图像。此图像来自 API,因此需要一些时间来加载。 是否可以在 API 的数据到达时禁用未选择的按钮?
这是按钮的代码:
@override
Widget build(BuildContext context) {
return ElevatedButton(
style: ElevatedButton.styleFrom(
padding: EdgeInsets.symmetric(horizontal: 5, vertical: 3),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(5.0),
),
primary: mainBgColor,
),
onPressed: showImage,
child: Text(
title,
),
);
}
这是功能:
showImage: =>_controller.buttonTap(getImage(quizImages.wrong));
-
这回答了你的问题了吗? How do I disable a Button in Flutter?
标签: flutter dart flutter-onpressed