     ///   - indexPath: The `IndexPath` of the cell.
     open func sizeForItem(at indexPath: IndexPath) -> CGSize {
         let message = messagesDataSource.messageForItem(at: indexPath, in: messagesCollectionView)
-        let context = cellLayoutContext(for: message, at: indexPath)
-        guard let itemHeight = context.itemHeight else {
-            fatalError("Unexpectedly received a nil itemHeight")
-        }
+        let itemHeight = cellContentHeight(for: message, at: indexPath)
         return CGSize(width: itemWidth, height: itemHeight)
     }
 }

// MARK: - Cache Invalidation

extension MessagesCollectionViewFlowLayout {

    /// Removes the cached layout information for a given `MessageType`.
    ///
    /// - Parameters:
    ///   - message: The `MessageType` whose cached layout information is to be removed.
    public func removeCachedAttributes(for message: MessageType) {
        removeCachedAttributes(for: message.messageId)
    }

    /// Removes the cached layout information for a `MessageType` with a given `messageId`.
    ///
    /// - Parameters:
    ///   - messageId: The id for the `MessageType` whose cached layout information is to be removed.
    public func removeCachedAttributes(for messageId: String) {
        layoutContextCache.removeObject(forKey: messageId as NSString)
    }

    /// Removes the cached layout information for all `MessageType`s.
    public func removeAllCachedAttributes() {
        layoutContextCache.removeAllObjects()
    }

    @objc

    }
}

// MARK: - Helpers

extension MessagesCollectionViewFlowLayout {

    internal func labelSize(for attributedText: NSAttributedString, considering maxWidth: CGFloat) -> CGSize {

        guard let cachedSize = attributedTextSizeCache.object(forKey: attributedText.hash as NSNumber)?.cgSizeValue else {
            let estimatedHeight = attributedText.height(considering: maxWidth)
            let estimatedWidth = attributedText.width(considering: estimatedHeight)

            let finalHeight = estimatedHeight.rounded(.up)
            let finalWidth = estimatedWidth > maxWidth ? maxWidth : estimatedWidth.rounded(.up)

            return CGSize(width: finalWidth, height: finalHeight)
        }

        return cachedSize
    }

    /// Convenience property for accessing the layout object's `MessagesCollectionView`.
