Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable splash highlight of FlatButton in Flutter?

I have a FlatButton. I don't want the splash highlight when the button is clicked. I tried changing the splash colour to transparent, but that didn't work. Here is the code for my FlatButton.

Widget button = new Container(   child: new Container(     padding: new EdgeInsets.only(bottom: 20.0),     alignment: Alignment.center,     child: new FlatButton(       onPressed: () {         _onClickSignInButton();       },       splashColor: Colors.transparent,       child: new Stack(         alignment: Alignment.center,         children: <Widget>[           new Image.asset('images/1.0x/button1.png',           ),           new Text("SIGN IN",             style: new TextStyle(                 color: Colors.white,                 fontWeight: FontWeight.bold,                 fontSize: 16.0               ),           )         ],       ),     ),   ), ); 
like image 251
Chaythanya Nair Avatar asked Mar 05 '18 09:03

Chaythanya Nair


People also ask

How do you remove splash color in flutter?

By setting both highlightColor and splashColor in your theme to Colors. transparent removed the ripple. You can hold some concerns that setting highlightColor might have some knock-on effects.

How do you stop a FlatButton flutter?

The RaisedButton / FlatButton / TextButton widget(s) can be disabled by assigning onPressed property to null . They can be disabled when onPressed property is not used at all. In order to make these widgets clickable, a function needs to be assigned to the onPressed property.

How do you change the TextButton splash color in flutter?

As Flat button is depricated, you have to use TextButton instead of it, but in text button there is no direct property to change splash color. So if you want to change splash color to transparent you can do it like this.

What is splash color in flutter?

splashColor. The splash color of the button's InkWell. The ink splash indicates that the button has been touched. It appears on top of the button's child and spreads in an expanding circle beginning where the touch occurred.


1 Answers

I'd expect an invisible highlight color to do what you want:

new FlatButton({   ...   splashColor: Colors.transparent,     highlightColor: Colors.transparent, // makes highlight invisible too }) 
like image 64
Günter Zöchbauer Avatar answered Oct 13 '22 01:10

Günter Zöchbauer