Set Show Image Icon Inside Alert Dialog Box in Flutter Example

In flutter the Alert dialog can support all the type of widgets inside it. We have so many times see Alert dialog with image icon added in it to represent icon of any company or organization. We have to use the Row widget in Alert dialog view in Title section in order to display Icon inside it. So in this tutorial we would Set Show Image Icon Inside Alert Dialog Box in flutter Android iOS Example Tutorial.

Contents in this project Set Show Image Icon Inside Alert Dialog Box in flutter Android iOS Example Tutorial:

1. Import material.dart package in your app’s main.dart file.

2. Create void main runApp() method and call our main MyApp class here directly.

3. Create MyApp class extends State less widget and call our AlertWithIcon() class in child section.

4. Create another class named as AlertWithIcon extends with StatefulWidget. In this class we would call the AlertWithIconWidget class using createState() method. This method would enable the mutable state management. We have to use multiple class organized structure because the Alert dialog needs to access the Application build context.

5. Create our main child AlertWithIconWidget class extends with State.

6. Create a function named as showAlert() with Build Context argument. Then we would call the showDialog() inbuilt method for displaying the Alert dialog message box. Inside the Alert dialog box we would display the Image using image URL.

  • title : Used to set Title of Alert dialog box. We’re using the Row widget in Title section and putting a Image widget and a Text widget in Row. With the use of Row widget both Image and Text should place one by one in single Row.
  • content : Used to set the Context text of Alert dialog box.
  • actions : Used to add action buttons in Alert dialog box. Actions supports multiple widgets.

7. Creating 1 Raised Button widget in Widget Build area of AlertWithIconWidget class.

8. Complete source code for main.dart file:

Screenshots:

Set Show Image Icon Inside Alert Dialog Box in flutter Example

2 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *