Search code examples
buttonflutterdartappbar

Align buttons below appBar without any space in flutter


I want to align the buttons just below the appBar but I am getting this:

enter image description here

I want to remove the space between buttons and the appBar. How can I achieve this?
This is the code:

Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(
          'Home',
        ),
      ),
      body: Column(
        children: <Widget>[
          Row(
            children: <Widget>[
              Column(
                children: <Widget>[
                  Container(
                    width: MediaQuery.of(context).size.width*0.5,
                    child: RaisedButton(
                      onPressed: (){},
                      child: Text('SORT'),
                    ),
                  )
                ],
              ),
              Column(
                children: <Widget>[
                  Container(
                    width: MediaQuery.of(context).size.width*0.5,
                    child: RaisedButton(
                      onPressed: (){},
                      child: Text('FILTER'),
                    ),
                  )
                ],
              )
            ],
          ),
        ],
      ),
    );
  }
}

Solution

  • Inside the RaisedButton, add this argument:

    materialTapTargetSize: MaterialTapTargetSize.shrinkWrap