This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
environment: | |
sdk: ">=2.7.0 <3.0.0" | |
dependencies: | |
flutter: | |
sdk: flutter | |
sendbird_sdk: ^3.0.11 | |
dash_chat: ^1.1.15 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:sendbird_sdk/sendbird_sdk.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final sendbird = SendbirdSdk(appId: "your_app_id"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final user = await sendbird.connect("unique_user_id"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Future<User> connect(String appId, String userId) async { | |
try { | |
final sendbird = SendbirdSdk(appId: appId); | |
final user = await sendbird.connect(userId); | |
return user; | |
} catch (e) { | |
print('connect: ERROR: $e'); | |
throw e; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Future<List<GroupChannel>> getGroupChannels() async { | |
try { | |
final query = GroupChannelListQuery() | |
..includeEmptyChannel = true | |
..order = GroupChannelListOrder.latestLastMessage | |
..limit = 15; | |
return await query.loadNext(); | |
} catch (e) { | |
print('getGroupChannels: ERROR: $e'); | |
return []; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Future<GroupChannel> createChannel(List<String> userIds) async { | |
try { | |
final params = GroupChannelParams()..userIds = userIds; | |
final channel = await GroupChannel.createChannel(params); | |
return channel; | |
} catch (e) { | |
print('createChannel: ERROR: $e'); | |
throw e; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@override | |
void initState() { | |
super.initState(); | |
SendbirdSdk().addChannelEventHandler('channel_list_view', this); | |
updateGroupChannels(); | |
} | |
@override | |
void dispose() { | |
SendbirdSdk().removeChannelEventHandler("channel_list_view"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
connect("sendbird_application_id", "unique_user_id").then((user) { | |
// Push next page or now call up channels to display | |
}).catchError((error) { | |
// Handle error | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Future<List<User>> getUsers() async { | |
try { | |
final query = ApplicationUserListQuery(); | |
List<User> users = await query.loadNext(); | |
return users; | |
} catch (e) { | |
print('getUsers: ERROR: $e'); | |
return []; | |
} | |
} |
OlderNewer