Flutter show toast above keyboard on IOS

921

You cannot show Fluttertoast above the keyboard in ios.

There are two options:

1.Change the gravity of toast to center

   Fluttertoast.showToast(
          msg: message,
          toastLength: Toast.LENGTH_SHORT,
          gravity: ToastGravity.CENTER,
          backgroundColor: Colors.red,
          textColor: Colors.white,
          fontSize: 16.0
      );
  1. Hide keyboard when showing toast at the bottom.

           FocusManager.instance.primaryFocus.unfocus();
    
Share:
921
Abdulmalek Dery
Author by

Abdulmalek Dery

Forward thinking mobile applications developer offering more than four years of experience building, integrating and testing top-quality clean code for high-paced businesses ranging from e-commerce to social media apps for Android & IOS devices on native and cross-platforms, and Led teams of +5 people to deliver +10 projects that resulted in $2M revenue

Updated on December 24, 2022

Comments

  • Abdulmalek Dery
    Abdulmalek Dery over 1 year

    I'm using fluttertoast 7.0.4 package to show toasts in my App but on IOS that toast isn't showed when the key board is opened "it actually appears behind the keyboard" this is my code

      Fluttertoast.showToast(
            msg: message,
            toastLength: Toast.LENGTH_SHORT,
            gravity: ToastGravity.BOTTOM,
            timeInSecForIosWeb: 1,
            backgroundColor: AppColors.strongOrange,
            textColor: Colors.white,
            fontSize: 16.0
    );
    

    is there any way to change the z-index and making it bigger than keyboard's z-index in flutter