How to remove the background when clicking on the text of a link?

1,885

Solution 1

If you are wrapping your text widget inside of a button then the button by default have feedback to let users know when they are pressed, if you don't need the feedback consider wrapping the button with a GestureDetector widget, and passing a function to the onTap property

Solution 2

Removed the background color on click with this code:

splashColor: Colors.transparent,  
highlightColor: Colors.transparent, 
Share:
1,885
user266322
Author by

user266322

Updated on December 18, 2022

Comments

  • user266322
    user266322 4 days

    I have a Text widget with a link to another screen, when clicked, the background appears. How do I remove the background when clicked? More in the photo

    Align(                            
        alignment: AlignmentDirectional.topStart,
        child: FlatButton(
        //color: Colors.redAccent,
        onPressed: () => Navigator.of(context).push(
          new MaterialPageRoute(builder: (context){
          return new SettingPage();
        }
        ),
        ),           
        padding: EdgeInsets.only(left:20.0),
        child: Row(
          mainAxisSize: MainAxisSize.min,
          children: <Widget>[
            Padding(
              padding: const EdgeInsets.all(8.0),
              child:SvgPicture.asset(iconSvgS5, height: 30.0, color:Colors.blueAccent),
            ),
            Padding(
              padding: const EdgeInsets.only(left:20.0),
              child: GestureDetector(
                onTap: () => Navigator.push(
                context,
                MaterialPageRoute(builder: (context) => FaqPage()),
              ),
              child:Text(
                "Вопросы и ответы", 
                style: TextStyle(
                  fontSize: 18.0
                ),                            
              ),
              ),
            ),
          ],
        ), 
      ),
    

    enter image description here

    • Yadu
      Yadu over 2 years
      just a text widget doesn't show any feedback when clicked, thats a button i guess, post the code
    • user266322
      user266322 over 2 years
      added code on question
    • Yadu
      Yadu over 2 years
      above code simply put will never render a feedback when tapped, theres might be parent widget which is rendering the feedback?
    • user266322
      user266322 over 2 years
      delivered all this code, can you see the code?
  • Yadu
    Yadu over 2 years
    as I have told you you have a GestureDetector inside a FlatButton widget, FlatButton is producing the Feedback, and GestureDetector inside FlatButton doesn't make any sense, as I can see you are trying push a screen SettingsPage using parent, and FAQ screen using GestureDetector! which is child of flatbutton why is that?