Skip to content

Commit

Permalink
refactor(iterable_extension): rename whereTruthy method (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
albertms10 committed Dec 20, 2021
1 parent 5fef6a6 commit 1a9b0fd
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/utils/iterable_extension.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:collection/collection.dart' show IterableExtension;

extension IterableExtension<E> on Iterable<E> {
/// Returns a filtered this Iterable excluding falsy values.
Iterable<E> get filterFalsy =>
Iterable<E> whereTruthy() =>
whereNot((element) => const [false, 0, '', null].contains(element));

/// Returns a list of consecutive values of this [Iterable]
Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/layout/detailed_figure.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class DetailedFigure<T> extends StatelessWidget {
Widget build(BuildContext context) {
final theme = Theme.of(context);

final filteredDetails = details.filterFalsy;
final filteredDetails = details.whereTruthy();

return ConditionalWidgetWrap(
condition: filteredDetails.length > 1 && tooltipMessage != null,
Expand Down
4 changes: 2 additions & 2 deletions test/iterable_extension_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import 'package:flutter_test/flutter_test.dart';

void main() {
group('IterableExtension', () {
group('.filterFalsy', () {
group('.whereTruthy', () {
test('should return this Iterable excluding falsy values', () {
expect(
const [true, false, 0, 1, 'Hello', 'world', '', null].filterFalsy,
const [true, false, 0, 1, 'Hello', 'world', '', null].whereTruthy(),
const [true, 1, 'Hello', 'world'],
);
});
Expand Down

0 comments on commit 1a9b0fd

Please sign in to comment.