Skip to main content

uploadPost method

Future<void> uploadPost ()

This function uploads the post finally, and navigate the success message or error message in Snack Bar.

params: None

returns:

  • Future<void>: Uploading post by contacting queries

Implementation

Future<void> uploadPost() async {
// {TODO: }
if (_imageFile == null) {
try {
await _dbFunctions.gqlAuthMutation(
PostQueries().uploadPost(),
variables: {
"text": _controller.text,
"organizationId": _selectedOrg.id,
"title": _titleController.text
},
);
_navigationService.showTalawaErrorSnackBar(
"Post is uploaded",
MessageType.info,
);
} on Exception catch (_) {
_navigationService.showTalawaErrorSnackBar(
"Something went wrong",
MessageType.error,
);
}
}
removeImage();
_controller.text = "";
_titleController.text = "";
notifyListeners();
}