google / tuple.dart

A library providing a tuple data structure
https://pub.dev/packages/tuple
BSD 2-Clause "Simplified" License
194 stars 26 forks source link

Please add tuple2 to map #18

Closed ride4sun closed 1 year ago

ride4sun commented 4 years ago

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)));
devoncarew commented 1 year ago

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