@@ -92,24 +92,20 @@ class _ParseLiveListWidgetState<T extends sdk.ParseObject>
92
92
listeningIncludes: listeningIncludes,
93
93
lazyLoading: lazyLoading,
94
94
preloadedColumns: preloadedColumns,
95
- ).then ((sdk.ParseLiveList <T > value) {
96
- if (value.size > 0 ) {
97
- setState (() {
98
- noData = false ;
99
- });
100
- } else {
101
- setState (() {
102
- noData = true ;
103
- });
104
- }
95
+ ).then ((sdk.ParseLiveList <T > livelist) {
105
96
setState (() {
106
- _liveList = value;
97
+ _noData = livelist.size == 0 ;
98
+ _liveList = livelist;
107
99
_liveList! .stream
108
100
.listen ((sdk.ParseLiveListEvent <sdk.ParseObject > event) {
109
101
if (event is sdk.ParseLiveListAddEvent ) {
110
- if (_animatedListKey.currentState != null )
102
+ if (_animatedListKey.currentState != null ) {
111
103
_animatedListKey.currentState!
112
104
.insertItem (event.index, duration: widget.duration);
105
+ }
106
+ setState (() {
107
+ _noData = livelist.size == 0 ;
108
+ });
113
109
} else if (event is sdk.ParseLiveListDeleteEvent ) {
114
110
_animatedListKey.currentState! .removeItem (
115
111
event.index,
@@ -126,15 +122,9 @@ class _ParseLiveListWidgetState<T extends sdk.ParseObject>
126
122
preLoadedData: () => event.object as T ,
127
123
),
128
124
duration: widget.duration);
129
- if (value.size > 0 ) {
130
- setState (() {
131
- noData = false ;
132
- });
133
- } else {
134
- setState (() {
135
- noData = true ;
136
- });
137
- }
125
+ setState (() {
126
+ _noData = livelist.size == 0 ;
127
+ });
138
128
}
139
129
});
140
130
});
@@ -146,17 +136,26 @@ class _ParseLiveListWidgetState<T extends sdk.ParseObject>
146
136
final GlobalKey <AnimatedListState > _animatedListKey =
147
137
GlobalKey <AnimatedListState >();
148
138
final ChildBuilder <T >? removedItemBuilder;
149
- bool noData = true ;
139
+ bool _noData = true ;
150
140
151
141
@override
152
142
Widget build (BuildContext context) {
153
143
if (_liveList == null ) {
154
144
return widget.listLoadingElement ?? Container ();
145
+ } else {
146
+ return Stack (
147
+ children: < Widget > [
148
+ if (widget.queryEmptyElement != null )
149
+ AnimatedOpacity (
150
+ opacity: _noData ? 1 : 0 ,
151
+ duration: widget.duration,
152
+ child: widget.queryEmptyElement,
153
+ ),
154
+ //_liveList isn't (checked above)
155
+ buildAnimatedList (_liveList! ),
156
+ ],
157
+ );
155
158
}
156
- if (noData) {
157
- return widget.queryEmptyElement ?? Container ();
158
- }
159
- return buildAnimatedList (_liveList! );
160
159
}
161
160
162
161
@override
0 commit comments