Flutter Toast

Karthik Ponnam
2 min readJul 8, 2020

--

Hello All,

In this article we will see how to use fluttertoast plugin to show Toast Messages

Lets Get started,

Before moving forward features provided by this plugin are

Features

  1. Full Controll of the Toast UI & Duration
  2. Toasts will be queued
  3. Remove a toast
  4. Clear the queue

How Plugin Works

This package internally uses Overlay to show toasts and manges queue using List

Code

First things first we need to import package in pubspec.yaml

Now lets get started with code

Add import statement for the package in your app

Now declare a variable flutterToast and intiate it in initState

Now we create a function to build the toast ui and show the toast

If you see _showToast function we find toast varibale which will be our toast UI you can coustamize it as per our needs.

Now this above peice of the code will trigger the package and show / add to queue

Now Call _showToast() based on user action

To cancel all the toasts call

// To remove present shwoing toastflutterToast.removeCustomToast()// To clear the queueflutterToast.removeQueuedCustomToasts();

Demo

We can also use it for loading purpose also, give it a try and let me know

Thanks for your time

Hope you like it, if yes **clap & share.**

https://twitter.com/PonnamKarthik

--

--

Karthik Ponnam
Karthik Ponnam

Written by Karthik Ponnam

❤️ to Code. Full Stack Developer, Flutter, Android Developer, Web Development, Known Languages Java, Python so on.,

Responses (1)