LOLWTFasdasd asdad
LOLWTFasdasd asdad

Reputation: 2903

How can I change the shape of the flutter showAboutDialog?

I'm calling the showAboutDialog as following:

onTap: () {
    showAboutDialog(
            context: context,
            applicationName: SettingsScreen.nameToDisplay,
            applicationLegalese: formatDateAppLegalese.format(DateTime.now()),
            applicationVersion: SettingsScreen.versionToDisplay,
            children: aboutBoxChildren,
        );
},

How can I change the shape of that dialog? I know how to style and alert dialog and add for example rounded corners but this is not transferable to the case of the showAboutDialog in flutter.

Adding corners to the children attribute does not have the right effect.

Is there a way to change the shape of that dialog and if how?

Upvotes: 5

Views: 582

Answers (2)

Ruble
Ruble

Reputation: 4824

This is how you can change the topic of only a certain dialog (or group of dialogs):

Theme(
  data: Theme.of(context).copyWith(
    dialogTheme: DialogTheme(
      shape: ...,
      backgroundColor: ...,
      alignment: ...,
    ),
  ),
  child: AboutDialog( // or any other dialog
    applicationName: ...,
    applicationVersion: ...,
    applicationIcon: ...,
    applicationLegalese: ...,
    children: ...,
  ),
);

Upvotes: 0

Moustapha
Moustapha

Reputation: 128

Considering this code:

onTap: () {
 showDialog(
  context: context,
  builder: (context) {
      return AboutDialog(
        applicationVersion: "1.0.2",
        applicationName: "Flutter app",
      );
    },
  );
},

You should modify your app theme to change the shape of your AboutDialog like this:

dialogBackgroundColor: Colors.grey,
dialogTheme: DialogTheme(
  shape: RoundedRectangleBorder(
    borderRadius: BorderRadius.circular(15),
  ),
  elevation: 5,
),

Upvotes: 3

Related Questions