How to detect clear icon press in ios keyboard in flutter?

This code is working for laptop keyboard delete key press. But it’s not printing backspace pressed in iphone and android clear icon pressed . How to achieve this?
Enter the first three digits of the 4-digit PIN incorrectly.
Press the X button on the keyboard to clear the previous field.
Observe that the focus remains on the current field (PIN), even after pressing the X button multiple times, preventing the user from easily correcting the mobile number
Pressing the X button should move the focus to the previous field and clear it, allowing the user to re-enter the correct information.

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

class OTPPinWidget extends StatefulWidget {
  final int length;
  final bool isPassword;
  final Function(String)? onComplete;
  final double height;
  final double width;
  final double spaceBetween;
  final double borderRadius;
  final double borderWidth;
  final Color borderColor;
  final Color fillColor;
  final MainAxisAlignment mainAxisAlignment;
  final bool isError;

  const OTPPinWidget({
    super.key,
    required this.length,
    required this.isPassword,
    this.onComplete,
    this.height = 54,
    this.width = 54,
    this.spaceBetween = 16,
    this.borderRadius = 8,
    this.borderWidth = 1,
    this.borderColor = Colors.black,
    this.fillColor = Colors.transparent,
    this.mainAxisAlignment = MainAxisAlignment.spaceBetween,
    this.isError = false,
  });

  @override
  _OTPPinWidgetState createState() => _OTPPinWidgetState();
}

class _OTPPinWidgetState extends State<OTPPinWidget> {
  late List<TextEditingController> _controllers;
  late List<FocusNode> _focusNodes;
  final FocusNode _keyboardFocusNode = FocusNode();

  @override
  void initState() {
    super.initState();
    _controllers = List.generate(widget.length, (_) => TextEditingController());
    _focusNodes = List.generate(widget.length, (_) => FocusNode());
  }

  @override
  void dispose() {
    for (var controller in _controllers) {
      controller.dispose();
    }
    for (var focusNode in _focusNodes) {
      focusNode.dispose();
    }
    _keyboardFocusNode.dispose();
    super.dispose();
  }

  void clearTextFields() {
    for (var controller in _controllers) {
      controller.clear();
    }
  }

  void handleBackspace() {
    for (int i = widget.length - 1; i >= 0; i--) {
      if (_focusNodes[i].hasFocus) {
        if (_controllers[i].text.isEmpty && i > 0) {
          _focusNodes[i - 1].requestFocus();
          _controllers[i - 1].clear();
          break;
        }
      }
    }
  }

  @override
  Widget build(BuildContext context) {
    if (widget.isError) {
      clearTextFields();
    }

    return Focus(
      focusNode: _keyboardFocusNode,
      onKeyEvent: (FocusNode node, KeyEvent event) {
        if (event is KeyDownEvent) {
          if (event.logicalKey == LogicalKeyboardKey.backspace ||
              event.logicalKey == LogicalKeyboardKey.clear) {
            print('Backspace pressed');
            handleBackspace();
            return KeyEventResult.handled;
          }
        }
        return KeyEventResult.ignored;
      },
      child: Row(
        mainAxisAlignment: widget.mainAxisAlignment,
        children: List.generate(widget.length, (index) {
          return Container(
            decoration: BoxDecoration(
              border: Border.all(
                  width: widget.borderWidth, color: widget.borderColor),
              borderRadius: BorderRadius.circular(widget.borderRadius),
            ),
            child: SizedBox(
              width: widget.width,
              height: widget.height,
              child: TextFormField(
                controller: _controllers[index],
                focusNode: _focusNodes[index],
                textAlign: TextAlign.center,
                keyboardType: TextInputType.number,
                obscureText: widget.isPassword,
                obscuringCharacter: '●',
                maxLength: 1,
                textInputAction: index == widget.length - 1
                    ? TextInputAction.done
                    : TextInputAction.next,
                inputFormatters: [
                  FilteringTextInputFormatter.allow(RegExp(r'[0-9]'))
                ],
                onChanged: (value) {
                  if (value.isNotEmpty) {
                    if (index < widget.length - 1) {
                      FocusScope.of(context).nextFocus();
                    } else {
                      FocusScope.of(context).unfocus();
                    }
                    final otp = _controllers
                        .map((controller) => controller.text)
                        .join();
                    if (widget.onComplete != null) {
                      widget.onComplete!(otp);
                    }
                  }
                },
                onTap: () {
                  _controllers[index].selection = TextSelection.fromPosition(
                    TextPosition(offset: _controllers[index].text.length),
                  );
                },
                decoration: InputDecoration(
                  contentPadding: EdgeInsetsDirectional.only(
                      start: 4, top: widget.isPassword ? 36 : 24),
                  counter: const SizedBox.shrink(),
                  enabledBorder: OutlineInputBorder(
                    borderRadius: BorderRadius.circular(widget.borderRadius),
                    borderSide:
                        const BorderSide(width: 0, color: Colors.transparent),
                  ),
                  focusedBorder: OutlineInputBorder(
                    borderRadius: BorderRadius.circular(widget.borderRadius),
                    borderSide:
                        const BorderSide(width: 0, color: Colors.transparent),
                  ),
                  fillColor: widget.fillColor,
                  filled: true,
                  isDense: true,
                  counterText: '',
                ),
                style: TextStyle(
                  color: const Color(0xFF221F1F),
                  fontSize: widget.isPassword ? 12 : 18,
                  fontWeight: FontWeight.w700,
                ),
              ),
            ),
          );
        }),
      ),
    );
  }
}

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật