MenuProperties constructor

MenuProperties({
  1. required String id,
  2. TextEditingController? textEditingController,
  3. dynamic onBackSpacePressed()?,
  4. dynamic onEmojiSelected(
    1. Category? category,
    2. Emoji emoji
    )?,
  5. dynamic onGifSelected(
    1. GiphyGif? gif
    )?,
  6. bool fromStack = true,
})

Implementation

MenuProperties(
    {required this.id,
    this.textEditingController,
    this.onBackSpacePressed,
    dynamic Function(Category? category, Emoji emoji)? onEmojiSelected,
    dynamic Function(GiphyGif? gif)? onGifSelected,
    this.fromStack = true}) {
  if (textEditingController != null) {
    focusNode = FocusNode();
    this.onEmojiSelected = (category, emoji) {
      if (Platform.I.isDesktop) {
        Get.find<MenuStateController>().close();
      }
      if (onEmojiSelected != null) {
        onEmojiSelected(category, emoji);
      }
    };
    this.onGifSelected = (gif) {
      if (Platform.I.isDesktop) {
        Get.find<MenuStateController>().close();
      }
      if (onGifSelected != null) {
        onGifSelected(gif);
      }
    };
    focusNode!.addListener(() {
      if (focusNode!.hasFocus &&
          Get.find<MenuStateController>().isOpened &&
          Get.find<MenuStateController>().currentMenu!.id != id) {
        Get.find<MenuStateController>().close();
      }
    });
  }
}