diff --git a/packages/stream_chat_flutter/lib/src/message_input.dart b/packages/stream_chat_flutter/lib/src/message_input.dart index 7c67c4d3..388df21b 100644 --- a/packages/stream_chat_flutter/lib/src/message_input.dart +++ b/packages/stream_chat_flutter/lib/src/message_input.dart @@ -355,11 +355,12 @@ class MessageInputState extends State { } void _startSlowMode() { - if (StreamChannel.of(context).channel.cooldownStartedAt != null) { - _cooldownStartedAt = StreamChannel.of(context).channel.cooldownStartedAt; + final channel = StreamChannel.of(context).channel; + if (channel.cooldownStartedAt != null) { + _cooldownStartedAt = channel.cooldownStartedAt; if (DateTime.now().difference(_cooldownStartedAt!).inSeconds < - StreamChannel.of(context).channel.cooldown!) { - _timeOut = StreamChannel.of(context).channel.cooldown! - + channel.cooldown!) { + _timeOut = channel.cooldown! - DateTime.now().difference(_cooldownStartedAt!).inSeconds; _slowModeTimer = Timer.periodic(const Duration(seconds: 1), (timer) { if (_timeOut == 0) {