0

this is my enum:

enum AddFriendType {
  email,
  phone,
  reciver_id,
}

this is my model class:

class FriendsModel {
  FriendsModel({
    this.parameter,
    this.type,
  });
  String? parameter;
  AddFriendType? type;
}

this is how I am using it:

Text("my cool text ${model.type} my cool text")
//my cool text  AddFriendType.phone my cool text

but I want it to be: "my cool text phone my cool text"

Maciek
  • 181
  • 3
  • 12

1 Answers1

1

You need to use .name like this:

Text("my cool text ${model.type!.name} my cool text") // result: my cool text phone my cool text
eamirho3ein
  • 16,619
  • 2
  • 12
  • 23
  • 1
    you are right, thx, small improvements, in my case I need to write "${model.type!.name}" cuz as I see I have nullable value of this enum, thank you for your help! – Maciek Nov 03 '22 at 11:17
  • sir, why adding duplicate answer when it already exist? – OMi Shah Nov 03 '22 at 11:18
  • @Maciek thanks for improvment, I updated my answer with that. glad to help. – eamirho3ein Nov 03 '22 at 11:20
  • @OMiShah I didn't search for duplicate it is not my job to do that, and it is not good behavior to give a down vote for this situation. if the question is duplicate you can report it as duplicate question. Sometime the duplicate question has key words that help other to find better solutions. – eamirho3ein Nov 03 '22 at 11:22
  • sir, you're a reputed members, it's our responsibility to at least search for a duplicate answer :) NW, I have removed by DV. :) – OMi Shah Nov 03 '22 at 11:25
  • I'm just here to help other people. Sometime the duplicate question has important key words that help other to find better solutions. Thanks @OMiShah – eamirho3ein Nov 03 '22 at 11:27
  • 1
    okay, NW :) :) :) – OMi Shah Nov 03 '22 at 11:28