小编cur*_*ind的帖子

如何禁用 NavigationRail 目的地图标中的波纹/飞溅效果?

我尝试过的东西:

  1. 用Theme小部件包装整个NavigationRail小部件并传入ThemeData,其中、、、全部设置为。splashColorhighlightColorhoverColorhintColorColors.transparent

尽管这似乎消除了最初的“轰动”,但“涟漪”效应仍然普遍存在(特别是onLongPress)。

       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'),
                ),
              ],
            ),
          )
Run Code Online (Sandbox Code Playgroud)
  1. 使用Semantics包装NavigationRail并将其设置为或仅将其包装在ExcludeSemantics小部件中excludeSemanticstrue

PS:我不想覆盖 …

flutter

5
推荐指数
2
解决办法
2655
查看次数

标签 统计

flutter ×1