title: Flutter Method Chanel Error java.lang.RuntimeException: Methods marked with @UiThread must be executed on the main thread
body: <p>Please Help Me.</p>
  <p>My Flutter Plugin Java can't return the list from native android please tell me to resolve it.</p>
  <p>I created a flutter plugin to connect to my watch. I created a method Chanel to execute android native SDK, but I am stuck because I can't send a value back to flutter in this function but other part works fine. Disturbing all of you help me fix this issue too.</p>
  <p>this error</p>
  <pre><code>W/System.err(21058): java.lang.RuntimeException: Methods marked with @UiThread must be executed on the main thread. Current thread: Binder:21058_2
  W/System.err(21058):    at io.flutter.embedding.engine.FlutterJNI.ensureRunningOnMainThread(FlutterJNI.java:1280)
  W/System.err(21058):    at io.flutter.embedding.engine.FlutterJNI.dispatchPlatformMessage(FlutterJNI.java:909)
  W/System.err(21058):    at io.flutter.embedding.engine.dart.DartMessenger.send(DartMessenger.java:72)
  W/System.err(21058):    at io.flutter.embedding.engine.dart.DartExecutor$DefaultBinaryMessenger.send(DartExecutor.java:384)
  W/System.err(21058):    at io.flutter.embedding.engine.dart.DartExecutor.send(DartExecutor.java:176)
  W/System.err(21058):    at io.flutter.plugin.common.EventChannel$IncomingStreamRequestHandler$EventSinkImplementation.success(EventChannel.java:221)
  W/System.err(21058):    at com.achatsocial.releep_watch_connect.ReleepWatchConnectPlugin$6.onDataResponse(ReleepWatchConnectPlugin.java:259)
  W/System.err(21058):    at a.b.f(Unknown Source:187)
  W/System.err(21058):    at a.b.b(Unknown Source:95)
  W/System.err(21058):    at b.a$a.onCharacteristicChanged(Unknown Source:82)
  W/System.err(21058):    at android.bluetooth.BluetoothGatt$1$8.run(BluetoothGatt.java:478)
  W/System.err(21058):    at android.bluetooth.BluetoothGatt.runOrQueueCallback(BluetoothGatt.java:780)
  W/System.err(21058):    at android.bluetooth.BluetoothGatt.access$200(BluetoothGatt.java:41)
  W/System.err(21058):    at android.bluetooth.BluetoothGatt$1.onNotify(BluetoothGatt.java:472)
  W/System.err(21058):    at android.bluetooth.IBluetoothGattCallback$Stub.onTransact(IBluetoothGattCallback.java:306)
  W/System.err(21058):    at android.os.Binder.execTransactInternal(Binder.java:1159)
  W/System.err(21058):    at android.os.Binder.execTransact(Binder.java:1123)
  </code></pre>
  <p>Example My Code Method channel</p>
  <pre><code>@Override
    public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) {
       if (call.method.equals(&quot;syncHealthData&quot;)) {
        int dataType = call.argument(&quot;dataType&quot;);
        // ArrayList healthDataList =
        // syncHealthDataByDataType(Constants.DATATYPE.Health_HistoryHeart);
        ArrayList lists = new ArrayList();
        YCBTClient.healthHistoryData(Constants.DATATYPE.Health_HistoryHeart, new BleDataResponse() {
  
          @Override
          public void onDataResponse(int i, float v, HashMap hashMap) {
  
            if (hashMap != null) {
              lists.addAll((ArrayList) hashMap.get(&quot;data&quot;));
              android.util.Log.e(&quot;history&quot;, &quot;hashMap=&quot; + hashMap.toString());
              result.success(lists);
            } else {
              android.util.Log.e(&quot;history&quot;, &quot;no ..hr..data....&quot;);
            }
          }
  
        });
      }  else {
        result.notImplemented();
      }
    }
  </code></pre>
  <pre><code> static Future&lt;dynamic&gt; syncHealthHr() async {
      var healthDataList =
          await _channel.invokeMethod('syncHealthData', {'dataType': 1208});
      return healthDataList;
    }
  </code></pre>