Remote DevTools for flutter_bloc. This package connects all Bloc (not working with Cubit) to the Remote Devtools Server, allowing the developer to inspect changes to the Blocs during runtime.
MIT License
65
stars
15
forks
source link
Does the Mappable interface reallly need to exist? #2
This library could do something similar. If the object is not an Map<String, dynamic>, then the toJson function gets called and in case it throws a NoSuchMethod, you can add no info, otherwise add the resulting json. This allows using standard codegen libraries, instead of having to wire everything up or making an MappableFromJson mixin which uses the toJson method (what im gonna use rn).
In dart:convert, in the json to string encoder, the dart objects are passed to the toEncodable function or are treated as dynamic and the toJson method is called https://github.com/dart-lang/sdk/blob/d86f0e2836d0941776f911dfc86ff444121fd29d/sdk/lib/convert/json.dart#L521 , and if an NoSuchMethod is thrown, the encoder catches the error and throws an encoding error.
This library could do something similar. If the object is not an Map<String, dynamic>, then the toJson function gets called and in case it throws a NoSuchMethod, you can add no info, otherwise add the resulting json. This allows using standard codegen libraries, instead of having to wire everything up or making an MappableFromJson mixin which uses the toJson method (what im gonna use rn).