Fluttertoast in Flutter
Fluttertoast is used to create a toast message by writing only one line of code. Below are some steps to create a Fluttertoast in Flutter. Basically here, we are creating a new Flutter application using a command prompt.
- Delete the default code from the main.dart file and write your own code.
- Now, add fluttertoast in dependencies of the pubspec.yaml file:
Some Properties of showToast:
- msg: toast message.
- toastLength: Duration of toast
- backgroundColor: Background color to be shown.
- textColor: Text color to be shown.
- fontSize: Font size of toast message.
If the font size is set to 25 the design changes as follows:
If the font size is set to 25 and gravity is set to ToastGravity.TOP the design changes as follows:
If the font size is set to 25 and gravity is set to ToastGravity.TOP and text color is set to pink the design changes as follows:
If you are Not Comfortable using Dependency then just use the below snippet:
.showSnackBar(SnackBar(content: Text(“My amazing message! O.o”)));
Customize SnackBar for your own.