12
12
import io .flutter .Build .API_LEVELS ;
13
13
import io .flutter .Log ;
14
14
import io .flutter .embedding .engine .dart .DartExecutor ;
15
- import io .flutter .plugin .common .JSONMethodCodec ;
16
15
import io .flutter .plugin .common .MethodCall ;
17
16
import io .flutter .plugin .common .MethodChannel ;
17
+ import io .flutter .plugin .common .StandardMethodCodec ;
18
+ import java .util .Arrays ;
18
19
import java .util .HashMap ;
19
20
import java .util .Map ;
20
21
@@ -37,7 +38,7 @@ public class BackGestureChannel {
37
38
* framework.
38
39
*/
39
40
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 );
41
42
channel .setMethodCallHandler (defaultHandler );
42
43
}
43
44
@@ -116,9 +117,13 @@ public void setMethodCallHandler(@Nullable MethodChannel.MethodCallHandler handl
116
117
@ TargetApi (API_LEVELS .API_34 )
117
118
@ RequiresApi (API_LEVELS .API_34 )
118
119
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 );
122
127
message .put ("progress" , backEvent .getProgress ());
123
128
message .put ("swipeEdge" , backEvent .getSwipeEdge ());
124
129
0 commit comments