Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
551 views
in Technique[技术] by (71.8m points)

dart - Inkwell Splash Effect not showing in Flutter when taps on it | Flutter

  Widget build(BuildContext context) {
    return Column(
      children: [
        InkWell(
          child: CircleAvatar(
            radius: 40,
            backgroundColor: Colors.grey[600],
            child: CircleAvatar(
              radius: 37,
              backgroundColor: Colors.white,
              child: Stack(
                children: [
                  Positioned(
                    top: 4,
                    left: 4,
                    bottom: 4,
                    right: 4,
                    child: IconButton(
                      icon: Icon(
                        icon,
                        size: 40,
                        color: Colors.grey[600],
                      ),
                      onPressed: onpress,
                    ),
                  ),
                ],
              ),
            ),
          ),
        ),
       

I didnt getting any splash effect or any other effect when tapping on this button. I add inkwell for different widgets also but its still not working

question from:https://stackoverflow.com/questions/65856671/inkwell-splash-effect-not-showing-in-flutter-when-taps-on-it-flutter

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

By checking your code onTap: (){}, is disable but by adding onTap still splash effect is not show so I added one extra Position widget and by this I given splash effect by using Material

InkWell(
                onTap: (){},
                splashColor: Colors.brown,
                child: CircleAvatar(
                  radius: 40,
                  backgroundColor: Colors.grey[600],
                  child: CircleAvatar(
                    radius: 37,
                    backgroundColor: Colors.white,
                    child: Stack(
                      children: [
                        Positioned(
                          top: 4,
                          left: 4,
                          bottom: 4,
                          right: 4,
                          child: IconButton(
                            icon: Icon(
                              Icons.ten_k,
                              size: 40,
                              color: Colors.grey[600],
                            ),
                            onPressed: () {},
                          ),
                        ),
                        Positioned(  // This I'm added
                          left: 0.0,
                          top: 0.0,
                          bottom: 0.0,
                          right: 0.0,
                          child: Material(   
                            type: MaterialType.transparency,
                            child: InkWell(
                              onTap: () async {
                                await Future.delayed(
                                    Duration(milliseconds: 200));

                              },
                            ),
                          ),
                        ),
                      ],
                    ),
                  ),
                ),
              ),

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...