registerPopGestureCallback method

void registerPopGestureCallback(
  1. VoidCallback callback,
  2. BuildContext context
)

注册系统返回手势的回调

当检测到 iOS 左滑返回手势时,会调用栈顶的回调函数。 多个页面可以同时注册回调,只有栈顶(最后注册)的回调会被调用。

参数:

  • context: 注册回调时的 BuildContext,作为回调的唯一标识, 同时用于检查页面是否还在顶层

示例:

PopscopeIos.registerPopGestureCallback(() {
  print('手势触发');
}, context);

// 组件销毁时注销
PopscopeIos.unregisterPopGestureCallback(context);

Implementation

void registerPopGestureCallback(
  VoidCallback callback,
  BuildContext context,
) {
  assert(
    context.mounted,
    'Cannot register callback with unmounted context',
  );
  throw UnimplementedError(
    'registerPopGestureCallback() has not been implemented.',
  );
}