Skip to content

Commit

Permalink
docs: update readme option docs (#59)
Browse files Browse the repository at this point in the history
* docs: update readme option docs

* remove redundant nullability docs
  • Loading branch information
renancaraujo authored Nov 1, 2023
1 parent bf64126 commit a673d9f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 28 deletions.
35 changes: 20 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,41 +113,35 @@ InfiniteList<String>(
// While set to `true`, the [onFetchData] callback will not be triggered
// and the [loadingBuilder] will be rendered.
//
// Is set to `false` by default and cannot be `null`.
// Is set to `false` by default.
isLoading: false,
// Indicates if an error has occurred.
//
// While set to `true`, the [onFetchData] callback will not be triggered
// and the [errorBuilder] will be rendered.
//
// Is set to `false` by default and cannot be `null`.
// Is set to `false` by default.
hasError: false,
// Indicates if the list should be reversed.
//
// If set to `true`, the list of items, [loadingBuilder] and [errorBuilder]
// will be rendered from bottom to top.
//
// Is set to `false` by default.
reverse: false,
// The duration with which calls to [onFetchData] will be debounced.
//
// Is set to a duration of 100 milliseconds by default and cannot be `null`.
// Is set to a duration of 100 milliseconds by default.
debounceDuration: const Duration(milliseconds: 100),
// The offset, in pixels, that the [scrollController] must be scrolled over
// The offset, in pixels, that the internal [ScrollView] must be scrolled over
// to trigger [onFetchData].
//
// This is useful for fetching data _before_ the user has scrolled all the
// way to the end of the list, so the fetching mechanism is more well hidden.
//
// For example, if this is set to `400.0` (the default), [onFetchData] will
// be called when the list is scrolled `400.0` pixels away from the bottom
// (or the top if [reverse] is `true`).
//
// This value must be `0.0` or greater, is set to `400.0` by default and
// cannot be `null`.
scrollExtentThreshold: 400.0,
//
// Defaults to the same as [RenderAbstractViewport.defaultCacheExtent], which is 250.
cacheExtent: 250.0,
// The amount of space by which to inset the list of items.
//
Expand Down Expand Up @@ -188,6 +182,17 @@ InfiniteList<String>(
//
// Is optional and can be `null`.
separatorBuilder: (context, index) => const Divider(),
// An optional [Axis] to be used by the internal [ScrollView] that defines
// the axis of scroll.
//
// Is set to `Axis.vertical` by default.
scrollDirection: Axis.vertical,
// An optional [ScrollPhysics] to be used by the internal [ScrollView].
//
// Default to tha same as [ScrollView].
physics: const AlwaysScrollableScrollPhysics(),
);
```

Expand Down
22 changes: 9 additions & 13 deletions lib/src/infinite_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import 'package:very_good_infinite_list/src/sliver_infinite_list.dart';
/// [onFetchData] will be called automatically.
///
/// The [itemCount], [hasReachedMax], [onFetchData] and [itemBuilder] must be
/// provided and cannot be `null`.
/// provided.
/// {@endtemplate}
///
/// See also:
Expand Down Expand Up @@ -64,7 +64,7 @@ class InfiniteList extends StatelessWidget {
/// {@template debounce_duration}
/// The duration with which calls to [onFetchData] will be debounced.
///
/// Is set to [defaultDebounceDuration] by default and cannot be `null`.
/// Is set to [defaultDebounceDuration] by default.
/// {@endtemplate}
final Duration debounceDuration;

Expand All @@ -79,7 +79,7 @@ class InfiniteList extends StatelessWidget {
/// {@template item_count}
/// The amount of items that need to be rendered by the [itemBuilder].
///
/// Is required and cannot be `null`.
/// Is required.
/// {@endtemplate}
final int itemCount;

Expand All @@ -89,7 +89,7 @@ class InfiniteList extends StatelessWidget {
/// While set to `true`, the [onFetchData] callback will not be triggered
/// and the [loadingBuilder] will be rendered.
///
/// Is set to `false` by default and cannot be `null`.
/// Is set to `false` by default.
/// {@endtemplate}
final bool isLoading;

Expand All @@ -99,7 +99,7 @@ class InfiniteList extends StatelessWidget {
/// While set to `true`, the [onFetchData] callback will not be triggered
/// and the [errorBuilder] will be rendered.
///
/// Is set to `false` by default and cannot be `null`.
/// Is set to `false` by default.
/// {@endtemplate}
final bool hasError;

Expand All @@ -109,7 +109,7 @@ class InfiniteList extends StatelessWidget {
///
/// While set to `true`, the [onFetchData] callback will not be triggered.
///
/// Is set to `false` by default and cannot be `null`.
/// Is set to `false` by default.
/// {@endtemplate}
final bool hasReachedMax;

Expand All @@ -124,17 +124,15 @@ class InfiniteList extends StatelessWidget {
/// Additionally, every call to this will be debounced by the provided
/// [debounceDuration].
///
/// Is required and cannot be `null`.
/// Is required.
/// {@endtemplate}
final VoidCallback onFetchData;

/// See [RenderViewportBase.cacheExtent]
final double? cacheExtent;

/// {@template padding}
/// The amount of space by which to inset the list of items.
///
/// Is optional and can be `null`.
/// The optional amount of space by which to inset the list of items.
/// {@endtemplate}
final EdgeInsets? padding;

Expand Down Expand Up @@ -165,15 +163,13 @@ class InfiniteList extends StatelessWidget {
///
/// If the [itemBuilder] returns a [ListTile], this is commonly used to render
/// a [Divider] between every tile.
///
/// Is optional and can be `null`.
/// {@endtemplate}
final IndexedWidgetBuilder? separatorBuilder;

/// {@template item_builder}
/// The builder used to build a widget for every index of the `itemCount`.
///
/// Is required and cannot be `null`.
/// Is required.
/// {@endtemplate}
final ItemBuilder itemBuilder;

Expand Down

0 comments on commit a673d9f

Please sign in to comment.