File tree Expand file tree Collapse file tree 3 files changed +46
-0
lines changed Expand file tree Collapse file tree 3 files changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -132,6 +132,12 @@ InfiniteList<String>(
132
132
// Is set to `false` by default.
133
133
reverse: false,
134
134
135
+ // Indicates if the extent of the ScrollView in the scrollDirection
136
+ // should be determined by the contents being viewed.
137
+ //
138
+ // Is set to `false` by default.
139
+ shrinkWrap: false,
140
+
135
141
// The duration with which calls to [onFetchData] will be debounced.
136
142
//
137
143
// Is set to a duration of 100 milliseconds by default.
Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ class InfiniteList extends StatelessWidget {
32
32
this .cacheExtent,
33
33
this .debounceDuration = defaultDebounceDuration,
34
34
this .reverse = false ,
35
+ this .shrinkWrap = false ,
35
36
this .isLoading = false ,
36
37
this .hasError = false ,
37
38
this .hasReachedMax = false ,
@@ -77,6 +78,14 @@ class InfiniteList extends StatelessWidget {
77
78
/// {@endtemplate}
78
79
final bool reverse;
79
80
81
+ /// Indicates if the extent of the [ScrollView] in the [scrollDirection]
82
+ /// should be determined by the contents being viewed.
83
+ ///
84
+ /// See also:
85
+ ///
86
+ /// * [CustomScrollView.shrinkWrap] , for more details about this flag.
87
+ final bool shrinkWrap;
88
+
80
89
/// {@template item_count}
81
90
/// The amount of items that need to be rendered by the [itemBuilder] .
82
91
///
@@ -207,6 +216,7 @@ class InfiniteList extends StatelessWidget {
207
216
return CustomScrollView (
208
217
scrollDirection: scrollDirection,
209
218
reverse: reverse,
219
+ shrinkWrap: shrinkWrap,
210
220
controller: scrollController,
211
221
physics: physics,
212
222
cacheExtent: cacheExtent,
Original file line number Diff line number Diff line change @@ -406,6 +406,36 @@ void main() {
406
406
tester.widget <CustomScrollView >(find.byType (CustomScrollView ));
407
407
expect (customScrollView.reverse, reverse);
408
408
});
409
+
410
+ testWidgets ('shrinkWrap' , (tester) async {
411
+ const shrinkWrap = true ;
412
+ await tester.pumpApp (
413
+ InfiniteList (
414
+ itemCount: 10 ,
415
+ onFetchData: emptyCallback,
416
+ itemBuilder: (_, i) => Text ('$i ' ),
417
+ shrinkWrap: shrinkWrap,
418
+ ),
419
+ );
420
+
421
+ final customScrollView =
422
+ tester.widget <CustomScrollView >(find.byType (CustomScrollView ));
423
+ expect (customScrollView.shrinkWrap, shrinkWrap);
424
+ });
425
+
426
+ testWidgets ('shrinkWrap defaults to false' , (tester) async {
427
+ await tester.pumpApp (
428
+ InfiniteList (
429
+ itemCount: 10 ,
430
+ onFetchData: emptyCallback,
431
+ itemBuilder: (_, i) => Text ('$i ' ),
432
+ ),
433
+ );
434
+
435
+ final customScrollView =
436
+ tester.widget <CustomScrollView >(find.byType (CustomScrollView ));
437
+ expect (customScrollView.shrinkWrap, false );
438
+ });
409
439
});
410
440
411
441
group ('centralized properties' , () {
You can’t perform that action at this time.
0 commit comments