Flutter iconbutton padding remove

To remove the padding around an IconButton in Flutter, you can use the ButtonTheme widget and set its padding property to EdgeInsets.zero.

Here is an example:

    
import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text('IconButton Padding'),
        ),
        body: Center(
          child: ButtonTheme(
            padding: EdgeInsets.zero,
            child: IconButton(
              icon: Icon(Icons.add),
              onPressed: () {
                print('Button pressed');
              },
            ),
          ),
        ),
      ),
    );
  }
}
    
  

In this example, we wrap the IconButton with the ButtonTheme widget and set its padding property to EdgeInsets.zero. This removes the default padding around the IconButton.

Now, when you run the app, you will see a button with the add icon in the center of the screen, and there will be no padding around it.

Leave a comment