jonataslaw / get_storage

A fast, extra light and synchronous key-value storage to Get framework
MIT License
359 stars 82 forks source link

Enums not supported #95

Open Nailik opened 2 years ago

Nailik commented 2 years ago

Hi, i try to store an enum.

I used json_annotation and json_serializable to hopefully generate the necessary functions but it didn't work.

@JsonEnum(alwaysCreate: true) enum Enum { @JsonValue(1) val1, @JsonValue(2) val2, @JsonValue(3) val3 }

Output: E/flutter (13450): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: Converting object to an encodable object failed: Instance of 'Enum'.

Did i miss anything? Would be nice if this is possible.

d-apps commented 2 years ago

Wouldn't be easier if you just have an enum conversion to string and vice versa?

So you could just store and retrieve String.

Nailik commented 2 years ago

Wouldn't be easier if you just have an enum conversion to string and vice versa?

So you could just store and retrieve String.

That's not typesafe because the stored string could be outside of the enums for some reason. With this there would also be a lot of code to be written for each enum.