pub struct MainThreadDispatcher { /* private fields */ }Expand description
Worker-safe handle for posting short operations to Flutter’s main thread.
Dispatch is always asynchronous, including when called from the main thread. This prevents a callback from unexpectedly re-entering Dart or mutable platform state in the middle of an FFI call.
Implementations§
Source§impl MainThreadDispatcher
impl MainThreadDispatcher
Sourcepub fn dispatch(
&self,
task: impl FnOnce() + Send + 'static,
) -> Result<(), DispatchError>
pub fn dispatch( &self, task: impl FnOnce() + Send + 'static, ) -> Result<(), DispatchError>
Posts task for a later turn of the main event loop.
Sourcepub fn is_main_thread(&self) -> bool
pub fn is_main_thread(&self) -> bool
Whether the caller is currently running on the owning main thread.
Trait Implementations§
Source§impl Clone for MainThreadDispatcher
impl Clone for MainThreadDispatcher
Source§fn clone(&self) -> MainThreadDispatcher
fn clone(&self) -> MainThreadDispatcher
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for MainThreadDispatcher
impl !UnwindSafe for MainThreadDispatcher
impl Freeze for MainThreadDispatcher
impl Send for MainThreadDispatcher
impl Sync for MainThreadDispatcher
impl Unpin for MainThreadDispatcher
impl UnsafeUnpin for MainThreadDispatcher
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more