Home > other >  How to remove ripple effect on clicking raised button flutter?
How to remove ripple effect on clicking raised button flutter?

Time:07-11

I have this dialog box and i have a question:

that when i click the close button, its giving this ripple effect which i dont want. I just want to pop the dialog box on pressed. This is the code


// Child 3 : Close Button
          Padding(
              padding: EdgeInsets.fromLTRB(width * .62, height * .153, 0, 0),
              child: RaisedButton(
                splashColor: Colors.white,
                hoverColor: Colors.blue,
                elevation: 0,
                onPressed: () {
                  setState(() {
                    Navigator.of(context).pop();
                  });
                },
                child: const Icon(
                  Icons.close,
                  color: Colors.black,
                ),
                color: Colors.transparent,
              ),
            ), 

--> https://imgur.com/a/sI1AAWV

CodePudding user response:

You can use GestureDetector that wont provide an extra ui decoration

GestureDetector(
  onTap: () {
    Navigator.of(context).pop();
  },
  child: const Icon(
    Icons.close,
    color: Colors.black,
  ),
),

Also you can use ElevatedButton instead of RaisedButton while it is deprecated.

ElevatedButton(
  style: ButtonStyle(
    elevation: MaterialStateProperty.all(0),
    overlayColor: MaterialStateProperty.all(Colors.green),
    backgroundColor: MaterialStateProperty.all(Colors.transparent),
  ),
  onPressed: () {},
  child: const Icon(
    Icons.close,
    color: Colors.black,
  ),
),

More about GestureDetector and ElevatedButton .

  • Related