Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 5934345

Browse files
committed
use StandardMethodCodec / Offset
1 parent a5a3467 commit 5934345

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

shell/platform/android/io/flutter/embedding/engine/systemchannels/BackGestureChannel.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@
1212
import io.flutter.Build.API_LEVELS;
1313
import io.flutter.Log;
1414
import io.flutter.embedding.engine.dart.DartExecutor;
15-
import io.flutter.plugin.common.JSONMethodCodec;
1615
import io.flutter.plugin.common.MethodCall;
1716
import io.flutter.plugin.common.MethodChannel;
17+
import io.flutter.plugin.common.StandardMethodCodec;
18+
import java.util.Arrays;
1819
import java.util.HashMap;
1920
import java.util.Map;
2021

@@ -37,7 +38,7 @@ public class BackGestureChannel {
3738
* framework.
3839
*/
3940
public BackGestureChannel(@NonNull DartExecutor dartExecutor) {
40-
this.channel = new MethodChannel(dartExecutor, "flutter/backgesture", JSONMethodCodec.INSTANCE);
41+
this.channel = new MethodChannel(dartExecutor, "flutter/backgesture", StandardMethodCodec.INSTANCE);
4142
channel.setMethodCallHandler(defaultHandler);
4243
}
4344

@@ -116,9 +117,13 @@ public void setMethodCallHandler(@Nullable MethodChannel.MethodCallHandler handl
116117
@TargetApi(API_LEVELS.API_34)
117118
@RequiresApi(API_LEVELS.API_34)
118119
private Map<String, Object> backEventToJsonMap(@NonNull BackEvent backEvent) {
119-
Map<String, Object> message = new HashMap<>(4);
120-
message.put("x", Float.isNaN(backEvent.getTouchX()) ? null : backEvent.getTouchX());
121-
message.put("y", Float.isNaN(backEvent.getTouchY()) ? null : backEvent.getTouchY());
120+
Map<String, Object> message = new HashMap<>(3);
121+
final float x = backEvent.getTouchX();
122+
final float y = backEvent.getTouchY();
123+
final Object touchOffset = (Float.isNaN(x) || Float.isNaN(y))
124+
? null
125+
: Arrays.asList(x, y);
126+
message.put("touchOffset", touchOffset);
122127
message.put("progress", backEvent.getProgress());
123128
message.put("swipeEdge", backEvent.getSwipeEdge());
124129

0 commit comments

Comments
 (0)