Widgets Nesting Level
The depths of widgets used inside a build
method.
Deeply nested widget trees are read and maintain. It's recommended to keep the widgets nesting level as small as possible.
A recommended WNL is 10 or less.
Config example
dart_code_metrics:
...
metrics:
...
widgets-nesting-level: 10
...
Example
class MyCustomWidget extends StatelessWidget {
const MyCustomWidget();
Widget build(BuildContext context) {
final widget = const Expanded(
child: Center(
child: Text('Hello, world!'),
),
);
return Material(
child: Column(
children: [
MyAppBar(title: Text('Example title')),
widget,
],
),
);
}
}
Widgets Nesting Level for this example is 5.