Flutter, How to remove white spaces around dialog box? Flutter, How to remove white spaces around dialog box? dart dart

Flutter, How to remove white spaces around dialog box?


Inside AlertDialog set contentPadding 0

contentPadding: EdgeInsets.zero,


make title to have Container, and add

width: MediaQuery.of(context).size.width,

Then give 0 (or what value you want to have for horizontal patting) to insetPadding like this:

insetPadding: EdgeInsets.symmetric(horizontal: 0),

Below is my example show dialog code, contains alertDialog with horizontal padding = 15 :

Future<void> _showLogoutDialog(BuildContext context) async {    return showDialog<void>(      context: context,      barrierDismissible: true,      builder: (BuildContext context) {        return AlertDialog(          titlePadding: EdgeInsets.only(top: 12, left: 24, right: 12),          contentPadding: EdgeInsets.only(top: 12, left: 24, bottom: 20),          insetPadding: EdgeInsets.symmetric(horizontal: 15),          titleTextStyle: TextStyle(            color: ColorStyles.primary_blue500,            fontFamily: 'Muli',            fontWeight: FontWeight.w500,            fontStyle: FontStyle.normal,            fontSize: 16.0,          ),          contentTextStyle: TextStyle(            color: ColorStyles.grey2,            fontFamily: 'Muli',            fontWeight: FontWeight.w400,            fontStyle: FontStyle.normal,            fontSize: 14.0,          ),          title: Container(            width: screenUsableHeight(context),            child: Row(              mainAxisSize: MainAxisSize.max,              mainAxisAlignment: MainAxisAlignment.spaceBetween,              children: [                Text('Log out'),                IconButton(                  icon: Icon(                    Icons.close,                    color: ColorStyles.grey2,                    size: 28,                  ),                  onPressed: () => Navigator.of(context).pop(),                  splashColor: Colors.transparent,                  highlightColor: Colors.transparent,                  tooltip: "close",                )              ],            ),          ),          //EN: Logging out          content: SingleChildScrollView(            child: ListBody(              children: <Widget>[                Text('Do you want to leave?'),              ],            ),          ),          actions: <Widget>[            FlatButton(              child: Text(                'Yes',                style: TextStyle(                  color: ColorStyles.primary_blue500,                  fontFamily: 'Muli',                  fontWeight: FontWeight.w500,                  fontStyle: FontStyle.normal,                  fontSize: 16.0,                ),              ), //EN: Yes              onPressed: () {                _logOut(context);              },            ),            FlatButton(              child: Text(                'No',                style: TextStyle(                  color: ColorStyles.grey2,                  fontFamily: 'Muli',                  fontWeight: FontWeight.w500,                  fontStyle: FontStyle.normal,                  fontSize: 16.0,                ),              ), //EN: No              onPressed: () {                Navigator.of(context).pop();              },            ),          ],        );      },    );  }

This looks like:

display of alert dialog


Don't use AlertDialog at all. Just send bodyProgress to showDialog

showDialog(context: context, builder: (_) => bodyProgress,);