hukusuke1007 / flamingo

[Flutter Library] Flamingo is a firebase firestore model framework library. 🐤
https://pub.dev/packages/flamingo
MIT License
118 stars 20 forks source link

Enum support #8

Closed stargazing-dino closed 4 years ago

stargazing-dino commented 4 years ago

Hi!

Is there currently no way to use enums?

enum Role { admin, editor, user }

class Profile extends Document<Profile> {
  // ...
  @Field()
  Role role;
}
[VERBOSE-2:ui_dart_state.cc(166)] Unhandled Exception: type 'String' is not a subtype of type 'Role' in type cast
#0      _AppState.build.<anonymous closure> 
package:approach_builder/main.dart:107
#1      _streamStartListening.<anonymous closure>.<anonymous closure> 
package:provider/src/async_provider.dart:30
#2      _rootRunUnary  (dart:async/zone.dart:1198:47)
#3      _CustomZone.runUnary  (dart:async/zone.dart:1100:19)
#4      _CustomZone.runUnaryGuarded  (dart:async/zone.dart:1005:7)
#5      _BufferingStreamSubscription._sendError.sendError  (dart:async/stream_impl.dart:378:15)
#6      _BufferingStreamSubscription._sendError  (dart:async/stream_impl.dart:394:16)
#7      _BufferingStreamSubscription._addError  (dart:async/stream_impl.dart:294:7)
#8      _SyncBroadcastStreamController._sendError.<anonymous closure>  (dart:async/broadcast_stream_controller.dart:400:20)
#9      _BroadcastStreamController._forEachListener  (dart:async/broadcast_stream_controller.dart:330:15)
hukusuke1007 commented 4 years ago

Sorry, response late. Firestore is not support enum. So flamingo is not support.

stargazing-dino commented 4 years ago

That's fine. I'll close for now

vladaman commented 3 years ago

Would it be possible to translate enum to String and back? It's just a serialization issue.