Answers for "toast in flutter"

7

toast flutter

# add this line to your dependencies
fluttertoast: ^7.1.1

Fluttertoast.showToast(
        msg: "This is Center Short Toast",
        toastLength: Toast.LENGTH_SHORT,
        gravity: ToastGravity.CENTER,
        timeInSecForIosWeb: 1,
        backgroundColor: Colors.red,
        textColor: Colors.white,
        fontSize: 16.0
    );
Posted by: Guest on July-31-2020
4

how to create a toast in flutter

You can show material design snackbars using the following code:

Scaffold.of(context).showSnackBar(SnackBar(
      content: Text("New Notification"),
    ));
   
In some cases, this will throw an error and it can be resolved using a workaround:

//Declare a GlobalKey
GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();

//Assing this key to the scaffold
Scaffold(
  key: _scaffoldKey,
  body: ...
)

//finally in the topmost code use this key in the following way
_scaffoldKey.showSnackBar(SnackBar(
      content: Text("New Notification"),
    ));
Posted by: Guest on May-14-2020
2

toast in flutter

Scaffold.of(context).showSnackBar(SnackBar(
      content: Text("Sending Message"),
    ));
Posted by: Guest on October-09-2020
-1

flutter toast

dependencies:
  fluttertoast: ^8.0.8
Posted by: Guest on August-05-2021
-2

flutter toast

dependencies:
  fluttertoast: ^7.1.6
Posted by: Guest on January-27-2021

Code answers related to "Dart"

Browse Popular Code Answers by Language