flutterdialogflutter-dialog

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


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

Click here for understanding the design


Solution

  • 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