mobileKeyBoardListener method

  1. @override
Future<void> mobileKeyBoardListener({
  1. dynamic onHeight(
    1. num height
    )?,
  2. dynamic onShow(
    1. KeyboardStatus status
    )?,
})
override

Implementation

@override
Future<void> mobileKeyBoardListener({Function(num height)? onHeight, Function(KeyboardStatus status)? onShow}) async {
  eventChannel.receiveBroadcastStream().listen(
    (event) {
      if (event["height"] is num) {
        if (onHeight != null) {
          onHeight(event["height"]);
        }
      }
      if (event["status"] is int) {
        if (onShow != null) {
          onShow(KeyboardStatus.values[event["status"]]);
        }
      }
    },
    onDone: () {
      if (kDebugMode) print("键盘监听移除");
    },
    onError: (e) {
      if (kDebugMode) print("键盘监听报错-----$e");
    },
  );
}