We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
how to count total items in grouped_list ?
The text was updated successfully, but these errors were encountered:
Hello @vohoangtuit,
Here is my solution to add the number of items in each group.
final List<MapEntry<String, int>> _textList = [ const MapEntry('Lorem', 0), const MapEntry('ipsum', 1), const MapEntry('dolor', 2), const MapEntry('sit', 3), const MapEntry('amet', 4), const MapEntry('consectetur', 5), const MapEntry('adipiscing', 6), const MapEntry('elit', 7), const MapEntry('sed', 8), const MapEntry('do', 9), const MapEntry('eiusmod', 10), const MapEntry('tempor', 11), const MapEntry('incididunt', 12), const MapEntry('ut', 14), ]; String groupBy(MapEntry<String, int> e) => e.value.isEven ? 'Even' : 'Odd';
Now you can use the groupHeaderBuilder and used the groupBy function to count the number of item in the group.
groupHeaderBuilder: (MapEntry<String, int> e) => Padding( padding: const EdgeInsets.all(8.0), child: Text( '${e.key} with ${_textList.where((test) { return groupBy(e) == groupBy(test); }).length} elements', textAlign: TextAlign.left, style: const TextStyle( fontSize: 20, fontWeight: FontWeight.bold, color: Colors.pink, ), ), ),
Result:
Sorry, something went wrong.
No branches or pull requests
how to count total items in grouped_list ?
The text was updated successfully, but these errors were encountered: