Raised button and alert dialog widget — Flutter

Hirudini Udugama
2 min readJan 16, 2021

Raised button is a button basically with an elevation. Alert dialog is a popup to give some message to user.

Now let us define a stateless widget for raised button and override the build method. Then return the container object that will contain a raised button as a child.

Let us use this raised button as the fourth element of the column.

Now you will receive the following output.

After clicking on the button we can perform an action. Let us try to do this.

We can call a function through onPressed method. Let us call for “viewJewellery”. As a parameter, pass context of build context which we are getting in the build function. After the build method let us create this method which accepts build context as a parameter. Now we can define our alert dialog. As parameters we can pass title and content. Then we have to show this dialog using showDialog function. Later we should define our builder which defines alertDialog.

Output as follows when you click on the button.

We can clean the code using function expressions.

Hope you got clear understand on Raised button and Alert dialog widget. See you in another article. Happy learning!!!

Hirudini Udugama

--

--