takePhoto method
The action for the take photo.
Implementation
@action
Future<void> takePhoto(BuildContext context) async {
if (_isSending || _isTakingPhoto) {
return;
}
_isTakingPhoto = true;
final isAtBottom = chatScrollController.isAtBottom();
final image = await ImagePicker().pickImage(source: ImageSource.camera);
if (image != null) {
final updated = _imageFiles.toList();
updated.add(
AssetImageInfo(
path: image.path,
),
);
_imageFiles = ObservableList<AssetImageInfo>.of(updated);
}
if (isAtBottom) {
WidgetsBinding.instance.addPostFrameCallback((_) {
chatScrollController.scrollToBottom();
});
}
_isTakingPhoto = false;
}