我没有在默认的 Flutter 按钮中找到任何属性。
但我想,我找到了声音的来源。这是 InkWell 小部件。我做了下面的技巧,它帮助了我:
class SilentBtn extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
color: Colors.red,
child: Material(
child: InkWell(
onTap: () => print('OnTap'),
enableFeedback: false,
child: Container(
width: 50,
height: 50,
child: Center(
child: Text(
':)',
style: TextStyle(color: Colors.white, fontSize: 16),
),
),
),
),
color: Colors.transparent,
),
);
}
}
Run Code Online (Sandbox Code Playgroud)
如果您设置了 'enableFeedback: false',您将不会在这里点击声音。如果是真的,那么声音是可以听到的。
| 归档时间: |
|
| 查看次数: |
1698 次 |
| 最近记录: |