creatVideoPost method
Implementation
Future<void> creatVideoPost(BuildContext context,
{String? communityId}) async {
log("creatVideoPost...");
if (amityVideo != null) {
bool isCommunity = (communityId != null) ? true : false;
if (isCommunity) {
await AmitySocialClient.newPostRepository()
.createPost()
.targetCommunity(communityId)
.video([amityVideo?.fileInfo as AmityVideo])
.text(textEditingController.text)
.post()
.then((AmityPost post) {
///add post to feedx
Provider.of<CommuFeedVM>(context, listen: false)
.addPostToFeed(post);
Provider.of<CommuFeedVM>(context, listen: false)
.scrollcontroller
.jumpTo(0);
})
.onError((error, stackTrace) async {
await AmityDialog().showAlertErrorDialog(
title: "Error!", message: error.toString());
});
} else {
await AmitySocialClient.newPostRepository()
.createPost()
.targetMe()
.video([amityVideo?.fileInfo as AmityVideo])
.text(textEditingController.text)
.post()
.then((AmityPost post) {
///add post to feedx
Provider.of<FeedVM>(context, listen: false).addPostToFeed(post);
Provider.of<FeedVM>(context, listen: false)
.scrollcontroller
.jumpTo(0);
})
.onError((error, stackTrace) async {
await AmityDialog().showAlertErrorDialog(
title: "Error!", message: error.toString());
});
}
}
}