Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Platform channel for predictive back in route transitions on android #49093

Merged
merged 6 commits into from
Mar 27, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
use StandardMethodCodec / Offset
  • Loading branch information
maRci002 committed Mar 27, 2024
commit 939293234425baf809ff3303bdd1532d9c55fb1f
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
import io.flutter.Build.API_LEVELS;
import io.flutter.Log;
import io.flutter.embedding.engine.dart.DartExecutor;
import io.flutter.plugin.common.JSONMethodCodec;
import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugin.common.StandardMethodCodec;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

Expand All @@ -37,7 +38,7 @@ public class BackGestureChannel {
* framework.
*/
public BackGestureChannel(@NonNull DartExecutor dartExecutor) {
this.channel = new MethodChannel(dartExecutor, "flutter/backgesture", JSONMethodCodec.INSTANCE);
this.channel = new MethodChannel(dartExecutor, "flutter/backgesture", StandardMethodCodec.INSTANCE);
channel.setMethodCallHandler(defaultHandler);
}

Expand Down Expand Up @@ -116,9 +117,13 @@ public void setMethodCallHandler(@Nullable MethodChannel.MethodCallHandler handl
@TargetApi(API_LEVELS.API_34)
@RequiresApi(API_LEVELS.API_34)
private Map<String, Object> backEventToJsonMap(@NonNull BackEvent backEvent) {
Map<String, Object> message = new HashMap<>(4);
message.put("x", Float.isNaN(backEvent.getTouchX()) ? null : backEvent.getTouchX());
message.put("y", Float.isNaN(backEvent.getTouchY()) ? null : backEvent.getTouchY());
Map<String, Object> message = new HashMap<>(3);
final float x = backEvent.getTouchX();
final float y = backEvent.getTouchY();
final Object touchOffset = (Float.isNaN(x) || Float.isNaN(y))
? null
: Arrays.asList(x, y);
message.put("touchOffset", touchOffset);
message.put("progress", backEvent.getProgress());
message.put("swipeEdge", backEvent.getSwipeEdge());

Expand Down