Skip to content

ScaffoldMessenger should be more helpful with nested Scaffolds #69929

Description

@Piinks

b/171649782

See discussion in #69907

Suggested by @mehmetf, ScaffoldMessenger could be more helpful if it could assert when registering a Scaffold that is a descendent of an already registered Scaffold.. something like:

void _register(ScaffoldState scaffold) {
    assert(_scaffolds does not contain any item that is a parent of the scaffold, 'You should really scope your Scaffolds....');
    _scaffolds.add(scaffold);
    if (_snackBars.isNotEmpty) {
      scaffold._updateSnackBar();
    }
  }

We should also expand the docs on troubleshooting nested Scaffolds, and add this to the migration guide as well:
https://api.flutter.dev/flutter/material/Scaffold-class.html
https://flutter.dev/docs/release/breaking-changes/scaffold-messenger

Metadata

Metadata

Assignees

Labels

a: error messageError messages from the Flutter frameworka: layoutSystemChrome and Framework's Layout Issuesa: qualityA truly polished experienceframeworkflutter/packages/flutter repository. See also f: labels.waiting for PR to land (fixed)A fix is in flight

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions