我尝试过的东西:
splashColor
,highlightColor
,{ {1}},hoverColor
均设置为hintColor
。尽管这似乎消除了最初的“飞溅”,但“涟漪”效应仍然很普遍(特别是 onLongPress )。
Colors.transparent
Theme(
data : ThemeData(
splashColor: Colors.transparent,
highlightColor: Colors.transparent
),
child: NavigationRail(
selectedIndex: _selectedIndex,
onDestinationSelected: (int index) {
setState(() {
_selectedIndex = index;
});
},
labelType: NavigationRailLabelType.selected,
destinations: [
NavigationRailDestination(
icon: Icon(Icons.favorite_border),
selectedIcon: Icon(Icons.favorite),
label: Text('First'),
),
NavigationRailDestination(
icon: Icon(Icons.bookmark_border),
selectedIcon: Icon(Icons.book),
label: Text('Second'),
),
NavigationRailDestination(
icon: Icon(Icons.star_border),
selectedIcon: Icon(Icons.star),
label: Text('Third'),
),
],
),
)
设置为excludeSemantics
或将其包裹在 ExcludeSemantics 小部件中PS:我不想从 MaterialApp 根目录覆盖整个 ThemeData ,尽管在 NavigationRailThemeData 中什么也看不到>引用此属性的类
PPS:在 NavigationRail.dart 文件(最后)中有一个 ColorScheme 类派生的类,该类具有语义小部件,该小部件具有需要禁用的所有属性,即 InkResponse 小部件,用于定义飞溅/波纹的颜色,形状和半径 NavigationRail.dart
以下是flutter.dev提供的用于方便复制/粘贴的示例代码(在dartpad.dev中效果很好)
true