How to create alert dialog on onTap on ListTile and select option to replace listTile value

124

First of all I would make a class to represent a member Member (with fields like id, name, role, whatever else you need).

Then have a Provider for managing the members data. It will contain list of members like List<Member> and methods to make changes for this list. For example: for changing member's role it will contain changeMemberRole(int memberID) method, that will modify data in that list and call notifyListeners(); in the end.

After that on the screen that need to show list of members I would get an instance of this provider, build all list tiles using it's data, and it will automatically rebuild the list once data changes.

Links that should help:

Simple state management (for understanding Providers)

Using modal bottom sheet (for dialog), but you can use AlertDialog as well

Share:
124
Advocate_Sandile
Author by

Advocate_Sandile

Updated on December 01, 2022

Comments

  • Advocate_Sandile
    Advocate_Sandile over 1 year

    Greetings everyone I'm new to flutter I need help implementing the simple feature of the Dialog.

    • I have a listTile consisting of members with different roles (Tressure, Secretary, Chair Person, and Ordinary Member)
    • Firstly I want to create an Alert dialog so that when I click on each listTile the dialog should pop up with the title "Change Member role" and below it should be the selectable options to set the selected option to the listTile
    • I need help creating the Alert dialog with these options and how to go about setting the text for the selected option to ListTile.
    • below is the link where I found the design, now I need the source code to implement the code

    Click here for understanding the design