美文网首页
Flutter 水波纹效果被覆盖、不显示问题

Flutter 水波纹效果被覆盖、不显示问题

作者: 北纬357 | 来源:发表于2021-02-23 20:10 被阅读0次
1、被覆盖水波纹的代码,InkWell包裹的Container不能设置背景色,会覆盖掉水波纹
    return Container(
        color: themeModule.themeData.backgroundColor,
        child: _buildStateWidget() != null
            ? _buildStateWidget() : Material(
          child: ListView.builder(
              itemCount: groupModule.groupLists.length,
              itemExtent: 50,
              itemBuilder: (context, index) {
                return Ink(
                  child: InkWell(
                    onTap: (){
                      _onClickItem(index);
                    },
                    child:  Container(
                      color:Colors.white, // InkWell包裹的Container不能设置背景色,会覆盖掉水波纹
                      child: _buildItemColumn(index),
                    ),
                  ),
                );
              }
          ),
        )
    );
1、修改后的代码,如果需要设置背景色,用Ink包裹设置背景色
    return Container(
        color: themeModule.themeData.backgroundColor,
        child: _buildStateWidget() != null
            ? _buildStateWidget() : Material(
          child: ListView.builder(
              itemCount: groupModule.groupLists.length,
              itemExtent: 50,
              itemBuilder: (context, index) {
                return Ink( // 需要设置背景色,用Ink包裹设置背景色
                  color:Colors.white,
                  child: InkWell(
                    onTap: (){
                      _onClickItem(index);
                    },
                    child:  Container(
                      child: _buildItemColumn(index),
                    ),
                  ),
                );
              }
          ),
        )
    );

相关文章

网友评论

      本文标题:Flutter 水波纹效果被覆盖、不显示问题

      本文链接:https://www.haomeiwen.com/subject/hdsdfltx.html