[ChannelListView] Convert listView.custom into listView.separated
Signed-off-by: Sahil Kumar <[email protected]>
This commit is contained in:
@@ -278,21 +278,19 @@ class _ChannelListViewState extends State<ChannelListView>
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
child = ListView.custom(
|
child = ListView.separated(
|
||||||
physics: AlwaysScrollableScrollPhysics(),
|
physics: AlwaysScrollableScrollPhysics(),
|
||||||
controller: _scrollController,
|
itemCount:
|
||||||
childrenDelegate: SliverChildBuilderDelegate(
|
channels.isNotEmpty ? channels.length + 1 : channels.length,
|
||||||
(context, i) {
|
separatorBuilder: (_, index) {
|
||||||
return _itemBuilder(context, i, channels);
|
if (widget.separatorBuilder != null) {
|
||||||
},
|
return widget.separatorBuilder(context, index);
|
||||||
childCount: (channels.length * 2) + 1,
|
}
|
||||||
findChildIndexCallback: (key) {
|
return _separatorBuilder(context, index);
|
||||||
final ValueKey<String> valueKey = key;
|
},
|
||||||
final index = channels.indexWhere(
|
itemBuilder: (context, index) {
|
||||||
(channel) => 'CHANNEL-${channel.id}' == valueKey.value);
|
return _listItemBuilder(context, index, channels);
|
||||||
return index != -1 ? (index * 2) : null;
|
},
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -483,20 +481,10 @@ class _ChannelListViewState extends State<ChannelListView>
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _itemBuilder(context, int i, List<Channel> channels) {
|
Widget _listItemBuilder(BuildContext context, int i, List<Channel> channels) {
|
||||||
if (i % 2 != 0) {
|
|
||||||
if (widget.separatorBuilder != null) {
|
|
||||||
return widget.separatorBuilder(context, i);
|
|
||||||
}
|
|
||||||
return _separatorBuilder(context, i);
|
|
||||||
}
|
|
||||||
|
|
||||||
i = i ~/ 2;
|
|
||||||
|
|
||||||
final channelsProvider = ChannelsBloc.of(context);
|
final channelsProvider = ChannelsBloc.of(context);
|
||||||
if (i < channels.length) {
|
if (i < channels.length) {
|
||||||
final channel = channels[i];
|
final channel = channels[i];
|
||||||
|
|
||||||
ChannelTapCallback onTap;
|
ChannelTapCallback onTap;
|
||||||
if (widget.onChannelTap != null) {
|
if (widget.onChannelTap != null) {
|
||||||
onTap = widget.onChannelTap;
|
onTap = widget.onChannelTap;
|
||||||
|
|||||||
Reference in New Issue
Block a user