Creating Custom built_value Serializers with BuiltValueSerializer

Gonçalo Palma
Flutter Community
Published in
3 min readFeb 8, 2019

--

Photo by Patrick Tomasso on Unsplash

When using built_value for JSON serializing and deserializing, we might have some cases that go beyond the capabilities of StandardJsonPlugin.

Imagine the following problem: you have an API endpoint that can give you two different types of data structures for the same value as shown in the following example:

In our flutter app, we might want to have an object that can have both values, and then we decide what we show in our Widgets.

--

--

Gonçalo Palma
Flutter Community

Author, Flutter Lead Developer @Pvotal Tech. Organizer, Google Developer Expert for Flutter and Dart, Lead Flutter Developer. 🌍 https://gpalma.pt/