Container wraps a child without configuring anything

ID

dart.performance.avoid_unnecessary_containers

Severity

info

Remediation Complexity

trivial

Remediation Risk

low

Remediation Effort

low

Resource

Redundancy

Language

Dart

Description

This Container only wraps its child and sets nothing else, so it adds a layout node for no benefit. Return the child directly.

Rationale

This Container only wraps its child and sets nothing else, so it adds a layout node for no benefit. Return the child directly.

The following code illustrates the pattern detected by this rule:

class Sample extends StatelessWidget {
  Widget wrapped(Widget child) {
    // FLAGGED: Container wraps a child without configuring anything
    return Container(child: child);
  }
}

Remediation

Follow secure coding practices and review the references below for detailed remediation guidance.

Configuration

This detector does not need any configuration.

© 2026 Xygeni. All rights reserved