You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: standardize README with pt-BR translation and update outdated
content
- Aligns the README format with other projects using a language
switcher and author section.
- Documents features missing since `0.5.1`, including controller,
pull-to-refresh, `onError`/`onItemsLoaded`, and `ListView`
passthrough.
- Removes the outdated pub/popularity badge because pub.dev no longer
exposes `popularityScore`.
-[Error and Analytics Callbacks](#error-and-analytics-callbacks)
39
49
-[Properties](#properties)
40
50
-[Contributing](#contributing)
41
51
-[License](#license)
@@ -67,15 +77,29 @@ It offers customization for manual/automatic loading, custom state widgets, and
67
77
- Insert null values at intervals (ads/dividers)
68
78
- Retry attempts limit on error
69
79
- Real item index mapping with intervals
80
+
-`ScrollInfinityController` for external refresh/retry
81
+
- Pull-to-refresh support
82
+
- Configurable load-more trigger threshold
83
+
-`onError` and `onItemsLoaded` callbacks for logging/analytics
84
+
- Passthrough of `physics`, `shrinkWrap`, `primary`, and `cacheExtent` to the underlying `ListView`
70
85
71
86
## Built With
72
87
73
-
-**[Flutter](https://flutter.dev/)**– A UI toolkit by Google for building beautiful, natively compiled applications for mobile, web, and desktop from a single codebase.
74
-
-**[Dart](https://dart.dev/)**– The programming language used for Flutter, optimized for building fast apps on any platform.
88
+
-**[Flutter](https://flutter.dev/)**- A UI toolkit by Google for building beautiful, natively compiled applications for mobile, web, and desktop from a single codebase.
89
+
-**[Dart](https://dart.dev/)**- The programming language used for Flutter, optimized for building fast apps on any platform.
75
90
76
91
## Getting Started
77
92
78
-
Install:
93
+
### Requirements
94
+
95
+
| Requirement | Version |
96
+
| ----------- | ---------- |
97
+
| Dart SDK | >=3.3.4 |
98
+
| Flutter SDK | >=1.17.0 |
99
+
100
+
Supports Android, iOS, web, Windows, Linux, and macOS.
101
+
102
+
### Installation
79
103
80
104
```bash
81
105
flutter pub add scroll_infinity
@@ -88,6 +112,8 @@ If `loadData` returns `null`, the error state is shown.
88
112
89
113
**Note:** Use a nullable type `T?` when using `interval`, as null values are inserted.
90
114
115
+
A fully configurable demo with every property wired to UI controls is available in the [example](example) directory.
116
+
91
117
### Basic Vertical Scroll
92
118
93
119
```dart
@@ -255,43 +281,125 @@ class _MyAppState extends State<MyApp> {
255
281
}
256
282
```
257
283
284
+
### Controller (Refresh & Retry)
285
+
286
+
Use a `ScrollInfinityController` to trigger `refresh()`/`retry()` from outside the widget (e.g. a button) and to read `isLoading`/`hasError`. Dispose it in `dispose()` since you created it.
287
+
288
+
```dart
289
+
final _controller = ScrollInfinityController();
290
+
291
+
@override
292
+
void dispose() {
293
+
_controller.dispose();
294
+
super.dispose();
295
+
}
296
+
297
+
@override
298
+
Widget build(BuildContext context) {
299
+
return ScrollInfinity<int>(
300
+
controller: _controller,
301
+
maxItems: _maxItems,
302
+
loadData: _loadData,
303
+
itemBuilder: _itemBuilder,
304
+
);
305
+
}
306
+
307
+
// Elsewhere, e.g. a FloatingActionButton:
308
+
onPressed: () => _controller.refresh(),
309
+
```
310
+
311
+
### Pull-to-Refresh
312
+
313
+
Set `enablePullToRefresh` to wrap the list in a `RefreshIndicator` that resets pagination back to `initialPageIndex`.
314
+
315
+
```dart
316
+
ScrollInfinity<int>(
317
+
enablePullToRefresh: true,
318
+
maxItems: _maxItems,
319
+
loadData: _loadData,
320
+
itemBuilder: _itemBuilder,
321
+
)
322
+
```
323
+
324
+
### Manual Loading
325
+
326
+
Set `automaticLoading` to `false` to show a "Load More" button instead of fetching automatically on scroll. Customize it with `loadMoreBuilder`.
327
+
328
+
```dart
329
+
ScrollInfinity<int>(
330
+
automaticLoading: false,
331
+
loadMoreBuilder: (action) {
332
+
return TextButton(
333
+
onPressed: action,
334
+
child: const Text('Load more'),
335
+
);
336
+
},
337
+
maxItems: _maxItems,
338
+
loadData: _loadData,
339
+
itemBuilder: _itemBuilder,
340
+
)
341
+
```
342
+
343
+
### Error and Analytics Callbacks
344
+
345
+
Use `onError` to log/report the raw exception thrown by `loadData`, and `onItemsLoaded` to observe successfully fetched items (e.g. analytics). Neither affects the build.
346
+
347
+
```dart
348
+
ScrollInfinity<int>(
349
+
onError: (error) => log('Failed to load items', error: error),
0 commit comments