Flutter Engine
The Flutter Engine
PlatformTaskQueue.java
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5package io.flutter.embedding.engine.dart;
6
7import android.os.Handler;
8import android.os.Looper;
9import androidx.annotation.NonNull;
10import io.flutter.util.HandlerCompat;
11
12/** A BinaryMessenger.TaskQueue that posts to the platform thread (aka main thread). */
14 // Use an async handler because the default is subject to vsync synchronization and can result
15 // in delays when dispatching tasks.
16 @NonNull private final Handler handler = HandlerCompat.createAsyncHandler(Looper.getMainLooper());
17
18 @Override
19 public void dispatch(@NonNull Runnable runnable) {
20 handler.post(runnable);
21 }
22}
static Handler createAsyncHandler(Looper looper)