Skip to content

Commit

Permalink
Fix code documentation + Add LetX & AlsoX extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
ashtanko committed Jun 6, 2024
1 parent 1dd20ef commit 9c935d8
Show file tree
Hide file tree
Showing 9 changed files with 217 additions and 109 deletions.
6 changes: 0 additions & 6 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,3 @@ jobs:
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: ./coverage/lcov.info

- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 0.1.4
- Fix code documentation.
- Add LetX extension functions.
- Add AlsoX extension functions.

## 0.1.3
- Add extension functions on nullable int, double, and bool.
- Add getter `orZero` and method `or` on int, double, and bool.
Expand Down
7 changes: 2 additions & 5 deletions example/nullx_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,8 @@ void main() {
);
// prints: 'You are an adult.'

void printValue(String value) {
// prints 'The value is: $value'
}

notEmpty(nullableString, printValue); // prints: example
// ignore: avoid_print
notEmpty(nullableString, (s) => print(s)); // prints: 'The value is: example'

const int? nullableInt2 = null;
nullableInt2.orZero; // Outputs: 0
Expand Down
19 changes: 12 additions & 7 deletions lib/src/collections.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ extension NullableMapExtension<T, R> on Iterable<T?> {
.map((element) => block(element as T));
}

/// Maps over the iterable, applying [block] to each non-null element and its index.
/// Maps over the iterable, applying [block] to each non-null element and
/// its index.
///
/// The [block] function should take a non-null `T` and an `int` index, and return a `R`.
/// The [block] function should take a non-null `T` and an `int` index,
/// and return a `R`.
///
/// Returns a new iterable with the results of applying [block] to
/// each non-null element of the original iterable and its index.
Expand All @@ -52,10 +54,11 @@ extension NullableMapExtension<T, R> on Iterable<T?> {
/// Extension on `List<T>?` to add a `whatIfNotNullOrEmpty` method.
///
/// This extension provides a convenient way to handle nullable lists.
/// The `whatIfNotNullOrEmpty` method takes two functions: `whatIf` and `whatIfNot`.
/// The `whatIfNotNullOrEmpty` method takes two functions: `whatIf` and
/// `whatIfNot`.
///
/// If the list is not null and not empty, it applies the `whatIf` function to the list.
/// If the list is null or empty, it calls the `whatIfNot` function.
/// If the list is not null and not empty, it applies the `whatIf` function
/// to the list. If the list is null or empty, it calls the `whatIfNot` function.
///
/// Example usage:
///
Expand All @@ -82,8 +85,10 @@ extension WhatIfNotNullOrEmptyExtension<T> on List<T>? {

/// Extension on `Iterable<T>?` to add an `isNullOrEmpty` getter.
///
/// This extension provides a convenient way to check if an iterable is null or empty.
/// The `isNullOrEmpty` getter returns true if the iterable is null or if it is empty.
/// This extension provides a convenient way to check if an iterable is null
/// or empty.
/// The `isNullOrEmpty` getter returns true if the iterable is null or if it
/// is empty.
///
/// Example usage:
///
Expand Down
Loading

0 comments on commit 9c935d8

Please sign in to comment.