Skip to content

Querying List<Enum> returns _Uint8ArrayView in dart #18

@queendevelopers

Description

@queendevelopers

gender is defined as an enum in Postgres, which accepts multiple values that could have {male, female, other}

Table
gender gender_enum[] DEFAULT '{female}',
Insert
gender': gender.map((e) => e.name).toList(),

I can see in the PgAdmin4 using a select query that displays gender as {male, female} value but when I use the select command in dart code it returns in _Uint8ArrayView format.

SELECT * FROM table
How can I solve this issue, please mention the best practices to deal with the Enum list.
Thank's in advance.


What I tried (current solution)

    Uint8List uint8List = Uint8List.fromList(gender);
    List<int> intListConverted = uint8List.toList();
    String stringValue = String.fromCharCodes(intListConverted);
   print(stringVlaue);   output ->    ��¸���male female other
    if (stringValue.contains(GenderEnum.male.name)) {
      genderList.add(GenderEnum.male);
    } else if (stringValue.contains(GenderEnum.female.name)) {
      genderList.add(GenderEnum.female);
    } else if (stringValue.contains(GenderEnum.other.name)) {
      genderList.add(GenderEnum.other);
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions