Delete a channel
Remove a channel from the channel list without deleting its messages. If a new message arrives in the channel, previous messages remain. To also delete messages, call the delete messages API separately.
This is a BaseChannel instance method.
Method
Dart
Future\<int\> delete(ErrorHandler handler);
Code example
Dart
BaseChannel channel = ...;
int? ret = await channel.delete((NCError? error) {
if (error == null || error.isSuccess) {
print('Channel deleted');
}
});
Delete channels by type
Delete channels and their messages for multiple channel types.
Method
Dart
static Future\<int\> deleteChannels(List\<ChannelType\> types, ErrorHandler handler);
Code example
Dart
int? ret = await BaseChannel.deleteChannels(
[ChannelType.direct, ChannelType.group],
(NCError? error) {
if (error == null || error.isSuccess) {
print('Delete succeeded');
}
},
);
Delete all channels
The SDK does not provide a dedicated "delete all" method. Use deleteChannels with all required channel types. Decide whether to include open channels and community channels based on your UI design.
Dart
await BaseChannel.deleteChannels(
[ChannelType.direct, ChannelType.group, ChannelType.system],
(NCError? error) { },
);