is it possible to define an enum with key value in flutter

hope I understood your question you can create an extension for ResponseStatus
and then set the codes or description for the enum

 extension ResponseStatusExtension on ResponseStatus  {

  static const statusCodes = {
    ResponseStatus.not_login: 904,

  };

  int get statusCode => statusCodes[this];

}

it’s more accessible and easy to use in my opinions

then you can access it buy using

  final  status = ResponseStatus.not_login;
  print('ResponseStatus name: ${status.statusCode}');

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top