-
Notifications
You must be signed in to change notification settings - Fork 105
/
my_list.dart
58 lines (53 loc) · 1.61 KB
/
my_list.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import 'package:flutter/material.dart';
import 'package:inview_notifier_list/inview_notifier_list.dart';
import 'box.dart';
class MyList extends StatelessWidget {
final int itemsLength;
final IsInViewPortCondition? inViewPortCondition;
final Widget? inViewArea;
final List<String> initialInViewIds;
final ScrollController? controller;
const MyList({
Key? key,
this.itemsLength = 30,
this.inViewPortCondition,
this.inViewArea,
this.initialInViewIds = const [],
this.controller,
}) : super(key: key);
@override
Widget build(BuildContext context) {
final IsInViewPortCondition condition = inViewPortCondition ??
(double deltaTop, double deltaBottom, double vpHeight) {
return deltaTop < (0.5 * vpHeight) && deltaBottom > (0.5 * vpHeight);
};
return Stack(
fit: StackFit.expand,
children: <Widget>[
InViewNotifierList(
controller: controller,
initialInViewIds: initialInViewIds,
isInViewPortCondition: condition,
itemCount: itemsLength,
builder: (BuildContext context, int index) {
return Container(
width: double.infinity,
height: 300.0,
color: Colors.blueGrey,
alignment: Alignment.center,
margin: EdgeInsets.symmetric(vertical: 50.0),
child: Box(id: '$index'),
);
},
),
IgnorePointer(
ignoring: true,
child: Align(
alignment: Alignment.center,
child: inViewArea ?? Container(),
),
),
],
);
}
}