Skip to content

ShowDialog is using the wrong context #28505

@MMonrad

Description

@MMonrad

Hello there,

The issues I addressed is in this line: https://github.com/flutter/flutter/blob/master/packages/flutter/lib/src/material/dialog.dart#L705

When the showDialog pageBuilder is trying to get the theme it is using the context from showDialog and not the context from the pageBuilder. The issue is that the context from showDialog can be invalid ex. when the application waked from a suspended state.

My suggestion to fix it, is to change:

final ThemeData theme = Theme.of(context, shadowThemeOnly: true);

to

final ThemeData theme = Theme.of(buildContext, shadowThemeOnly: true);

Steps to Reproduce

  1. Call Show dialog, with a textfield as child
  2. Suspend the entire application
  3. Wake up the application
  4. Go to landscape mode and see the application will crash

Logs

Metadata

Metadata

Assignees

Labels

c: crashStack traces logged to the consolef: material designflutter/packages/flutter/material repository.frameworkflutter/packages/flutter repository. See also f: labels.waiting for PR to land (fixed)A fix is in flight

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions