Invalid constant value

6,930

Have your tried simply returning PopupMenuItem without const modifier like below?

PopupMenuItem _createMenuItems(final String a) {
   return PopupMenuItem(
     value: a,
     child: Text(a),
   );
}
Share:
6,930
Sokheang Khun
Author by

Sokheang Khun

Just try to be better in coding life.

Updated on December 15, 2022

Comments

  • Sokheang Khun
    Sokheang Khun over 1 year

    I created a method below to loop through my list because I don't want to write again and again of these few lines but the parameter I pass to the Text widget and also value argument are error and it said Invalid constant value. How can I achieve this? I'm new to flutter. Please help me.

      PopupMenuItem _createMenuItems(final String a) {
        return const PopupMenuItem(
          value: a,
          child: Text(a),
        );
      }