diff --git a/src/widget/toaster/mod.rs b/src/widget/toaster/mod.rs index 60c9899e..8f1e436c 100644 --- a/src/widget/toaster/mod.rs +++ b/src/widget/toaster/mod.rs @@ -176,13 +176,19 @@ impl Toasts { let id = self.toasts.len(); self.toasts.push_back(toast); - let on_close = self.on_close; - crate::command::future(async move { - #[cfg(feature = "tokio")] - tokio::time::sleep(duration).await; - on_close(id) - }) + #[cfg(feature = "tokio")] + { + let on_close = self.on_close; + crate::command::future(async move { + tokio::time::sleep(duration).await; + on_close(id) + }) + } + #[cfg(not(feature = "tokio"))] + { + Command::none() + } } /// Remove a [`Toast`]