how you can remove the padding between the icon for the drawer in the appBar and the Search Icon in flutter

0

i make appBar and add a drawer to it and also search icon the problem there is padding between the icon for the Drawer and the search icon And I can't get rid of it

this the code:

class _HomeState extends State<Home> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        titleSpacing: 0,
        title: Row(
          mainAxisAlignment: MainAxisAlignment.start,
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            IconButton(
              icon: Icon(Icons.search),
              onPressed: () {},
            ),
          ],
        ),
        
        backgroundColor: Color(0xffffffff),
        elevation: 1,
        toolbarHeight: 40.0,
        iconTheme: IconThemeData(color: Colors.grey),
      ),
      drawer: Drawer(
        child: ListView(
          children: <Widget>[],
        ),
      ),
      body: Container(
        height: MediaQuery.of(context).size.height,
        width: MediaQuery.of(context).size.width,
        color: Color(0xfffafafa),
        child: Text("hello"),
      ),
    );
  }
}
flutter
dart
asked on Stack Overflow Nov 4, 2020 by Muhammed Jack • edited Jan 13, 2021 by shorol

3 Answers

0

Wrapping your search button with this will reduce the padding.

Not sure how much of the padding you wanted to remove.

SizedBox(
  width: 10.0,
  child: IconButton(
    padding: EdgeInsets.zero,
    icon: Icon(Icons.search),
    onPressed: () {},
  ),
),
answered on Stack Overflow Nov 4, 2020 by Will Hlas
0

Add this lines to remove default padding of IconButton:

IconButton(
     constraints: BoxConstraints(),
     padding: const EdgeInsets.all(0),),
answered on Stack Overflow Jan 13, 2021 by shorol
0

Try like this

appBar: AppBar(
      title: Text(title),
      backgroundColor: kPrimaryLightColor,
      actions: <Widget>[
        Padding(
            padding: EdgeInsets.only(right: 20.0),
            child: GestureDetector(
              onTap: () {},
              child: Icon(
                Icons.message_rounded,
                size: 30.0,
              ),
            )),
answered on Stack Overflow Jan 13, 2021 by Taqi Tahmid Tanzil

User contributions licensed under CC BY-SA 3.0