1212import io .flutter .Build .API_LEVELS ;
1313import io .flutter .Log ;
1414import io .flutter .embedding .engine .dart .DartExecutor ;
15- import io .flutter .plugin .common .JSONMethodCodec ;
1615import io .flutter .plugin .common .MethodCall ;
1716import io .flutter .plugin .common .MethodChannel ;
17+ import io .flutter .plugin .common .StandardMethodCodec ;
18+ import java .util .Arrays ;
1819import java .util .HashMap ;
1920import 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