google/tuple.dart

Please add tuple2 to map

Closed this issue · 1 comments

It would be nice to have the convenience method toMap based on the types. Thanks

I think that is way too complicated.... I wish Dart would have Extension Methods like C# and I can add a library of static converters.
https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/extension-methods

      Map<String, String> result = Map<String, String>.fromEntries(
          tuple2object.map((f) => MapEntry(f.item1, f.item2)));

I believe this can now be supported by Dart's extension methods (released as part of Dart 2.7).