Skip to content

Commit

Permalink
added capitalize List<String>
Browse files Browse the repository at this point in the history
  • Loading branch information
LeonardoRosaa committed Feb 9, 2022
1 parent 77c31fd commit 34bd007
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/src/string_capitalize_base.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
/// Matches all characteres
final foundLetters = RegExp(r'\w+');

extension ListCapilize on List<String> {
/// Update the first letter to capital all items of this List<String>
List<String> capitalize() {
return map((e) => e.capitalize()).toList();
}
}

extension StringCapitalize on String {
/// Does transform uppercase first letter of this string
/// and this is be empty, returns an empty
Expand Down
8 changes: 8 additions & 0 deletions test/string_capitalize_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,13 @@ void main() {
expect('dart'.startsWithCapital(), false);
});
});

group('capitalize list', () {
test('should be capitalize all items', () {
final result = ['peter', 'parker', 'and', 'mary', 'jane'].capitalize();

expect(result, ['Peter', 'Parker', 'And', 'Mary', 'Jane']);
});
});
});
}

0 comments on commit 34bd007

Please sign in to comment.