當(dāng)前位置:
首頁 >
如何在 Flutter 中禁用默认的 Widget 飞溅效果
發(fā)布時(shí)間:2025/3/19
37
豆豆
生活随笔
收集整理的這篇文章主要介紹了
如何在 Flutter 中禁用默认的 Widget 飞溅效果
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
如何在 Flutter 中禁用默認(rèn)的 Widget 飛濺效果
默認(rèn)情況下,許多 Flutter Material Design 小部件在被選中時(shí)會(huì)顯示飛濺效果。
這適用于IconButton,InkWell,ListTile和許多其他部件。
如果您正在創(chuàng)建一個(gè)完全自定義的設(shè)計(jì)并希望在整個(gè)應(yīng)用程序范圍內(nèi)禁用此功能,您需要做的就是:
MaterialApp(theme: ThemeData(splashColor: Colors.transparent,highlightColor: Colors.transparent,hoverColor: Colors.transparent,), )或者,您可以通過插入父Theme小部件將其應(yīng)用于某個(gè)小部件子樹:
Theme(data: Theme.of(context).copyWith(splashColor: Colors.transparent,highlightColor: Colors.transparent,hoverColor: Colors.transparent,)child: child, )您還可以直接為特定小部件禁用此功能:
IconButton(splashColor: Colors.transparent,highlightColor: Colors.transparent,hoverColor: Colors.transparent,icon: someIcon,onPressed: someCallback, )總結(jié)
以上是生活随笔為你收集整理的如何在 Flutter 中禁用默认的 Widget 飞溅效果的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 使用 FocusScopeNode 在
- 下一篇: Dart 异步编程之 Isolate 和