Dart Analyze logoDart Analyze/
DRT-W1195

Use `ColoredBox`DRT-W1195

Major severityMajor
Anti-pattern categoryAnti-pattern

DO use ColoredBox when Container has only a Color.

A Container is a heavier Widget than a ColoredBox, and as bonus, ColoredBox has a const constructor.

BAD:

Widget buildArea() {
  return Container(
    color: Colors.blue,
    child: const Text('hello'),
  );
}

GOOD:

Widget buildArea() {
  return const ColoredBox(
    color: Colors.blue,
    child: Text('hello'),
  );
}