Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/display translations in documentation comments (#52)
Adds optional to generate comments with localization details.
- Loading branch information
Showing
10 changed files
with
279 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
extension ListExtensions<E> on List<E> { | ||
/// Maps a list of elements to a list of elements of another type. | ||
/// | ||
/// The [predicate] filters elements that are passed to the [transform] function. | ||
/// This does not change the order or index of the elements. | ||
/// The [transform] function is called for each element in the list with its respective index and maps it to a new element. | ||
List<T> mapIndexedWhere<T>(T Function(int index, E element) transform, | ||
[bool Function(int index, E element)? predicate]) { | ||
final result = <T>[]; | ||
for (var i = 0; i < length; i++) { | ||
if (predicate != null ? predicate(i, this[i]) : true) { | ||
result.add(transform(i, this[i])); | ||
} | ||
} | ||
return result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import 'package:flappy_translator/src/extensions/list_extensions.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
void main() { | ||
test('mapIndexedWhere', () { | ||
expect( | ||
['a', 'b', 'c'].mapIndexedWhere((i, e) => e).toList(), ['a', 'b', 'c']); | ||
expect(['a', 'b', 'c'].mapIndexedWhere((i, e) => i).toList(), [0, 1, 2]); | ||
// with filter | ||
expect( | ||
['aasd', 'bas', 'cas', 'a', 'asdas'] | ||
.mapIndexedWhere((i, e) => e.length) | ||
.toList(), | ||
[4, 3, 3, 1, 5]); | ||
expect( | ||
['aasd', 'bas', 'cas', 'a', 'asdas'] | ||
.mapIndexedWhere((i, e) => e, (i, e) => e.length != 3) | ||
.toList(), | ||
['aasd', 'a', 'asdas']); | ||
expect( | ||
['123456', '123', '123', '12345678', '123456'] | ||
.mapIndexedWhere((i, e) => e[i], (i, e) => e.length != 3) | ||
.toList(), | ||
['1', '4', '5']); | ||
}); | ||
} |
Oops, something went wrong.