Open matanlurey opened 7 years ago
I'd love to see asConverter()
and asCodec()
as constructors on the Converter
and Codec
classes. Constructors are the easiest thing to add to core libraries, too, since they don't have any backwards-incompatibility edge cases.
I'm down with MapConverter
if you think that use-case is widespread enough to be worth a class.
Lots of Dart and Flutter users don't even know about
package:convert
ordart:convert
, or when they do it seems difficult to get started - most code samples I've seen folks write static functions in the form ofT convert<S, T>(S input)
and ignore these packages.Could we consider adding some simple short-hand classes/functions to make use easier?
MapConverter
that uses a backingMap<S, T>
to do simple conversions:asConverter<S, T>(S Func1<T> function)
asCodec<S, T>(Converter<S, T> encoder, Converter<T, S> decoder)