Map to Class in Dart

后端 未结 4 1935
北海茫月
北海茫月 2021-01-11 17:44

Is there a standard way to convert a map to an object of a user defined class?

In Python you can do MyClass(**map) which basically unwraps the map into named argumen

4条回答
  •  生来不讨喜
    2021-01-11 18:17

    There is no built-in way.
    You can use one of the serialization packages like

    • https://pub.dev/packages/json_serializable
    • https://pub.dev/packages/built_value
    • ...

提交回复
热议问题