sentry-dart icon indicating copy to clipboard operation
sentry-dart copied to clipboard

replace `dynamic` to `Object?` whenever possible

Open marandaneto opened this issue 4 years ago • 5 comments

we never know if a dynamic is a nullable field, also dynamic disables type checking. should we replace it for better type checking?

@ueman @bruno-garcia

marandaneto avatar Jun 25 '21 08:06 marandaneto

I wonder how that works with JSON (de) serialization, since that historically always has been Map<String,dynamic>. Though I suspect that it works. Other than that I see nothing which should stop us from doing that.

ueman avatar Jun 25 '21 08:06 ueman

yeah I think at runtime would not change anything, and I also think that we don't call any method directly on dynamic by skipping type check, we always cast before using the dynamic objects anyway.

marandaneto avatar Jun 25 '21 08:06 marandaneto

this would be ideally done with https://github.com/getsentry/sentry-dart/issues/510 so we do a single breaking change in the hints signature, as they are all dynamic

marandaneto avatar Jun 25 '21 08:06 marandaneto

Json decoding returns a Map<String, dynamic> so x.fromJson(Map<String, dynamic>) has to stay that way. A couple of things like extras will have to stay because of that, too. However, there's still a lot of code to improve left.

ueman avatar Jul 02 '21 19:07 ueman

dynamic decode returns dynamic but can be always cast right, why do we need to keep fromJson as dynamic? I don't see why it'd be a problem.

marandaneto avatar Jul 03 '21 11:07 marandaneto

In favor of https://github.com/getsentry/sentry-dart/issues/510

marandaneto avatar Oct 18 '22 14:10 marandaneto