diff --git a/packages/altive_lints/lib/src/lints/avoid_shrink_wrap_in_list_view.dart b/packages/altive_lints/lib/src/lints/avoid_shrink_wrap_in_list_view.dart index 19a92ab..8861038 100644 --- a/packages/altive_lints/lib/src/lints/avoid_shrink_wrap_in_list_view.dart +++ b/packages/altive_lints/lib/src/lints/avoid_shrink_wrap_in_list_view.dart @@ -5,6 +5,42 @@ import 'package:custom_lint_builder/custom_lint_builder.dart'; import '../utils/types_utils.dart'; +/// An `avoid_shrink_wrap_in_list_view` rule that discourages +/// using `shrinkWrap` with `ListView`. +/// +/// This property causes performance issues by requiring +/// the list to fully layout its content upfront. +/// Instead of `shrinkWrap`, consider using slivers +/// for better performance with large lists. +/// +/// ### Example +/// +/// #### BAD: +/// +/// ```dart +/// ListView( +/// shrinkWrap: true, // LINT +/// children: [ +/// Text('Hello'), +/// Text('World'), +/// ], +/// ); +/// ``` +/// +/// #### GOOD: +/// +/// ```dart +/// CustomScrollView( +/// slivers: [ +/// SliverList.list( +/// children: [ +/// Text('Hello'), +/// Text('World'), +/// ], +/// ), +/// ], +/// ); +/// ``` class AvoidShrinkWrapInListView extends DartLintRule { const AvoidShrinkWrapInListView() : super(code: _code);