Skip to content

showPlatformDialog is not respecting theme on Material #463

@martin-braun

Description

@martin-braun

This is a platform dialog spawned on Material:

image
              await showPlatformDialog<void>(
                context: context,
                builder: (_) => PlatformAlertDialog(
                  title: Text(l10n.cardCabinetDetailActionStartGrow),
                  content:
                      Text(l10n.cardCabinetDetailActionStartGrowInstructions),
                  actions: <Widget>[
                    PlatformDialogAction(
// ...

This is a platform date picker spawned on Material:

image
                        DateTime? startGrowTime = await showPlatformDatePicker(
                            context: context,
                            initialDate: now.add(const Duration(seconds: 1)),
                            firstDate: DateTime.now(),
                            lastDate: now.add(const Duration(days: 90)),
                            material: (context, data) =>
                                MaterialDatePickerData(),
                            cupertino: (context, data) =>
                                CupertinoDatePickerData(
                                  mode: CupertinoDatePickerMode.dateAndTime,
                                ));

Notice how the DateTime picker has a greenish tint to it? My ThemeData is has a colorScheme that was seeded from #0A7A34 and no explicit themes or colors are used here. So, the platform dialog does something differently here and it is wrong.

I noticed the solution is to set the PlatformAlertDialog color to surfaceContainerHigh:

                  material: (_, __) => MaterialAlertDialogData(
                    backgroundColor: theme.colorScheme.surfaceContainerHigh,
                  ),

Defaults should be changed here I guess.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions