google / built_collection.dart

Immutable Dart collections via the builder pattern.
https://pub.dev/packages/built_collection
BSD 3-Clause "New" or "Revised" License
275 stars 52 forks source link

tighten `MapBuilder` factory parameter #279

Open ahmednfwela opened 1 year ago

ahmednfwela commented 1 year ago

MapBuilder currently has the factory: factory MapBuilder([map = const {}]) I think it should be

factory MapBuilder([map = const <K, V>{}])

there are also other instances where dynamic is used instead of strict types, is that intentional? e.g. https://github.com/google/built_collection.dart/issues/241

davidmorgan commented 1 year ago

Thanks Ahmed!

These APIs were designed way back in the Dart 1 days when type annotations didn't matter so much and there was no type inference.

I have a plan for a pile of changes like the one you suggest at some point, to modernize the APIs; but they are breaking changes so they will take some work to land. I'm not sure when that will happen.

Actually now that Dart 3 has launched the right time might be now, I will give it some thought.

Thanks!

ahmednfwela commented 1 year ago

that's really great! I will be happy to help contribute with some PRs once you share your plan 🙂