Skip to content

Commit

Permalink
chore: Add doc comment
Browse files Browse the repository at this point in the history
  • Loading branch information
naipaka committed Jul 29, 2024
1 parent 9108af2 commit eb7444e
Showing 1 changed file with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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: <Widget>[
/// Text('Hello'),
/// Text('World'),
/// ],
/// );
/// ```
///
/// #### GOOD:
///
/// ```dart
/// CustomScrollView(
/// slivers: <Widget>[
/// SliverList.list(
/// children: [
/// Text('Hello'),
/// Text('World'),
/// ],
/// ),
/// ],
/// );
/// ```
class AvoidShrinkWrapInListView extends DartLintRule {
const AvoidShrinkWrapInListView() : super(code: _code);

Expand Down

0 comments on commit eb7444e

Please sign in to comment.