### downTo Source: https://github.com/birjuvachhani/screwdriver/blob/main/EXTENSIONS.md Creates an IntRange starting from this to `end` inclusively with a default step size of 1. ```APIDOC ## downTo ### Description Creates an `IntRange` starting from this to `end` inclusively with a default step size of 1. ### Method METHOD ### Endpoint int.downTo(end) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **IntRange** (object) - An integer range object. #### Response Example None ``` -------------------------------- ### rangeTo Source: https://github.com/birjuvachhani/screwdriver/blob/main/EXTENSIONS.md Creates an `IntRange` starting from this integer up to the specified `end` value, inclusively, with a default step size of 1. ```APIDOC ## METHOD rangeTo ### Description Creates an `IntRange` starting from this to `end` inclusively with default step size of 1. ### Method METHOD ### Endpoint N/A (Instance Method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters #### Path Parameters - **end** (int) - Required - The end value of the range (inclusive). ### Response #### Success Response (IntRange) - Returns an `IntRange` object representing the sequence of integers from `this` to `end`. ### Request Example ```dart // Example usage: // final range = 1.rangeTo(5); // This creates an IntRange from 1 to 5. ``` ``` -------------------------------- ### Example Issue Submission Source: https://github.com/birjuvachhani/screwdriver/blob/main/CONTRIBUTING.md When submitting an issue, provide details about what you are trying to achieve, where you have already looked for information, and where you expected to find the relevant details. ```text What are you trying to do or find out more about? Where have you looked? Where did you expect to find this information? ``` -------------------------------- ### IO Extensions Source: https://github.com/birjuvachhani/screwdriver/blob/main/README.md Examples of IO extensions for file operations, including listening for modifications, clearing file content, checking if a file is empty, appending strings, and concatenating file contents. ```dart file.onModified(() => print('file modified')); file.clear(); // flushes all the data of file file.isEmpty; file.appendString('hello'); file << 'some text'; file1 + file2; // appends file2 content at the end of file1 ``` -------------------------------- ### File I/O Operations Source: https://github.com/birjuvachhani/screwdriver/blob/main/example/example.md Provides examples of extension methods for file operations, including listening for modifications, clearing content, checking emptiness, appending strings, and concatenating files. ```dart file.onModified(() => print('file modified')); ``` ```dart file.clear(); ``` ```dart file.isEmpty; ``` ```dart file.appendString('hello'); ``` ```dart file << 'some text'; ``` ```dart file1 + file2; ``` -------------------------------- ### Integer Utility Methods Source: https://github.com/birjuvachhani/screwdriver/blob/main/example/example.md Provides examples of integer extension methods for checking divisibility, converting to boolean, formatting with leading zeros, checking for leap years, and repeating an action. ```dart 20.isDivisibleBy(5); ``` ```dart 0.asBool; ``` ```dart 6.twoDigits; ``` ```dart 2020.isLeapYear; ``` ```dart 10.repeat((count) => print(count)); ``` -------------------------------- ### String Extensions Source: https://github.com/birjuvachhani/screwdriver/blob/main/README.md Examples of various string manipulation extensions, including capitalization, checking for blank strings, type conversion, wrapping, binary checks, email validation, reversing, word splitting, JSON parsing, and prefix removal. ```dart 'hello'.capitalized; // Hello ' '.isBlankl // true; '45'.toIntOrNull(); // 45 'html'.wrap('<','>'); // '1010111010001'.isBinary; // true 'test@example.com'.isEmail; // true 'abcd'.reversed; // dcba 'This is a test'.words; // ['this', 'is', 'a', 'test'] '{"name":"John"}'.parseJson(); // map: {name:John} '#hello'.removePrefix('#'); // hello ``` -------------------------------- ### Collection Extensions Source: https://github.com/birjuvachhani/screwdriver/blob/main/README.md Illustrates various extensions for collections, including appending elements, getting the first or last elements, dropping or taking elements, checking conditions for all elements, grouping, counting, selecting random elements, finding max by a property, set intersection, and adding pairs to maps. ```dart users << User(name: 'John'); // appends user to users list users.firstOrNull; users.drop(5); users.takeLast(3); user.all((u) => u.age > 18); // returns bool cars.groupBy((car) => car.color); cars.count((car) => car.isPorsche); cars.random(); cars.maxBy((car) => car.price); cars.intersect(otherCars); {'name': 'John'} << Pair('email','john@doe.com'); ``` -------------------------------- ### Iterator Extensions Source: https://github.com/birjuvachhani/screwdriver/blob/main/EXTENSIONS.md Extensions for Iterator to advance and get the next element. ```APIDOC ## next ### Description Advances the iterator and returns the current element. ### Type METHOD ### Example ```dart final iterator = [1, 2, 3].iterator; print(iterator.next()); // 1 print(iterator.next()); // 2 print(iterator.next()); // 3 ``` ``` -------------------------------- ### toFixedString Source: https://github.com/birjuvachhani/screwdriver/blob/main/EXTENSIONS.md Returns the integer as a string, padded with leading zeros if it is less than the specified width. For example, 5.toFixedString(2) returns '05', 20.toFixedString(3) returns '020', and 20.toFixedString(2) returns '20'. ```APIDOC ## METHOD toFixedString ### Description Returns `int` as string which has a zero appended as prefix if `this` is less than `width` digits. e.g. 5.toFixedString(2) // returns '05', 20.toFixedString(3) // returns '020', 20.toFixedString(2) // returns '20'. ### Method METHOD ### Endpoint N/A (Instance Method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters #### Path Parameters - **width** (int) - Required - The target number of digits for the string representation. ### Response #### Success Response (String) - Returns a string representation of the integer, padded with leading zeros to meet the specified `width`. ### Request Example ```dart // Example usage: // 5.toFixedString(2) // returns '05' // 20.toFixedString(3) // returns '020' // 20.toFixedString(2) // returns '20' ``` ``` -------------------------------- ### post Source: https://github.com/birjuvachhani/screwdriver/blob/main/EXTENSIONS.md Runs a given action no sooner than in the next event-loop iteration, after all micro-tasks have run. ```APIDOC ## post ### Description Runs a given action no sooner than in the next event-loop iteration, after all micro-tasks have run. ### Parameters - **action** (Function) - The function to execute. ``` -------------------------------- ### foldRight Source: https://github.com/birjuvachhani/screwdriver/blob/main/EXTENSIONS.md Accumulates value starting with initialValue value and applying operation from right to left to each element and current accumulator value. ```APIDOC ## foldRight ### Description Accumulates value starting with `initialValue` value and applying `operation` from right to left to each element and current accumulator value. ### Method METHOD ### Endpoint N/A (Extension Method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) Returns the accumulated value after applying the operation from right to left. #### Response Example None ``` -------------------------------- ### length Source: https://github.com/birjuvachhani/screwdriver/blob/main/EXTENSIONS.md Returns the number of digits in the integer. For example, 3.length returns 1, 21.length returns 2, and 541.length returns 3. ```APIDOC ## GETTER length ### Description Returns no. of digits e.g. 3.length // returns 1, 21.length // returns 2, 541.length // returns 3. ### Method GETTER ### Endpoint N/A (Instance Getter) ### Parameters None ### Response #### Success Response (int) - Returns the number of digits in the integer. ``` -------------------------------- ### foldRightIndexed Source: https://github.com/birjuvachhani/screwdriver/blob/main/EXTENSIONS.md Accumulates value starting with initialValue value and applying operation from right to left to each element with its index in the original list and current accumulator value. ```APIDOC ## foldRightIndexed ### Description Accumulates value starting with `initialValue` value and applying `operation` from right to left to each element with its index in the original list and current accumulator value. ### Method METHOD ### Endpoint N/A (Extension Method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) Returns the accumulated value after applying the operation with index from right to left. #### Response Example None ``` -------------------------------- ### Scope Functions: apply and run Source: https://github.com/birjuvachhani/screwdriver/blob/main/example/example.md Illustrates the use of scope functions `apply` for object configuration and `run` for executing a block of code with the object and returning a result. ```dart final User user = User(name: 'John').apply((user){ user.age = 24; user.email = 'john@doe.com'; }); ``` ```dart final String age = user.run((u)=> (u.age + 20).toString()); ``` -------------------------------- ### digits Source: https://github.com/birjuvachhani/screwdriver/blob/main/EXTENSIONS.md Returns a list of the digits of the integer. For example, 12345.digits returns [1, 2, 3, 4, 5], and 8564.digits returns [8, 5, 6, 4]. ```APIDOC ## GETTER digits ### Description Returns list of digits of `this` e.g. 12345.digits // returns [1, 2, 3, 4, 5], 8564.digits // returns [8, 5, 6, 4]. ### Method GETTER ### Endpoint N/A (Instance Getter) ### Parameters None ### Response #### Success Response (List) - Returns a list of integers representing the digits of the number. ``` -------------------------------- ### TODO Source: https://github.com/birjuvachhani/screwdriver/blob/main/EXTENSIONS.md Always throws `UnimplementedError` stating that the operation is not implemented. ```APIDOC ## TODO ### Description Always throws `UnimplementedError` stating that the operation is not implemented. ### Throws - `UnimplementedError` - Indicates that the operation is not yet implemented. ``` -------------------------------- ### now Source: https://github.com/birjuvachhani/screwdriver/blob/main/EXTENSIONS.md A shorthand for `DateTime.now`. ```APIDOC ## now ### Description A shorthand for `DateTime.now`. ### Returns - `DateTime` - The current date and time. ``` -------------------------------- ### Import IO Extensions Source: https://github.com/birjuvachhani/screwdriver/blob/main/README.md Use this import statement to access IO-specific extensions provided by the Screwdriver package. ```dart import 'package:screwdriver/screwdriver_io.dart'; ``` -------------------------------- ### wrap Source: https://github.com/birjuvachhani/screwdriver/blob/main/EXTENSIONS.md Wraps the string between a prefix and suffix. Uses prefix as suffix if suffix is null. ```APIDOC ## wrap ### Description Wraps the string between a prefix and suffix. Uses the prefix as the suffix if the suffix is null. ### Method METHOD ### Endpoint String.wrap(String prefix, [String? suffix]) ### Example ```dart 'hello'.wrap("*"); // returns *hello* 'html'.wrap('<','>'); // returns `` ``` ``` -------------------------------- ### + Source: https://github.com/birjuvachhani/screwdriver/blob/main/EXTENSIONS.md Allows adding a record entry to the map. ```APIDOC ## + ### Description Allows to add a record entry to `this` map. ### Method METHOD ### Endpoint N/A (Instance method on Map) ### Parameters - `key` (dynamic) - The key of the entry to add. - `value` (dynamic) - The value of the entry to add. ### Request Example ```dart final myMap = {'a': 1}; myMap + ('b', 2); ``` ### Response #### Success Response - The map is modified in place with the new entry. #### Response Example ```dart {'a': 1, 'b': 2} ``` ``` -------------------------------- ### asBool Source: https://github.com/birjuvachhani/screwdriver/blob/main/EXTENSIONS.md Returns true for non-zero integer values, similar to C language. Returns false for zero. ```APIDOC ## GETTER asBool ### Description Returns true for non-zero values just like C language. e.g. 1.asBool // returns true, 0.asBool // returns false, 452.asBool // returns true. ### Method GETTER ### Endpoint N/A (Instance Getter) ### Parameters None ### Response #### Success Response (bool) - Returns `true` if the integer is non-zero, `false` otherwise. ``` -------------------------------- ### buildString Source: https://github.com/birjuvachhani/screwdriver/blob/main/EXTENSIONS.md Allows building a string with `StringBuffer` using a `builder` function. ```APIDOC ## buildString ### Description Allows building a string with `StringBuffer` using a `builder` function. ### Parameters - **builder** (Function) - A function that takes a `StringBuffer` and appends content to it. ``` -------------------------------- ### Int Extensions Source: https://github.com/birjuvachhani/screwdriver/blob/main/README.md Demonstrates integer extensions for checking divisibility, converting to boolean, formatting with leading zeros, checking for leap years, and repeating an action a specified number of times. ```dart 20.isDivisibleBy(5); // true 0.asBool; // false 6.twoDigits; // '06' 2020.isLeapYear; // true 10.repeat((count) => print(count)); ``` -------------------------------- ### plus Source: https://github.com/birjuvachhani/screwdriver/blob/main/EXTENSIONS.md Alias for add operation. ```APIDOC ## METHOD plus ### Description Alias for add operation. ### Method METHOD ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response #### Success Response (200) - **result** (number) - The result of the addition. ### Response Example N/A ``` -------------------------------- ### take Source: https://github.com/birjuvachhani/screwdriver/blob/main/EXTENSIONS.md Alias for the 'only' method. Returns a new Map containing only the entries whose keys are present in the provided list of keys. ```APIDOC ## take ### Description Alias for `only` method. Returns a new `Map` with the same keys and values but only contains the keys present in `keys`. ### Method METHOD ### Endpoint N/A (Instance method on Map) ### Parameters - `keys` (Iterable) - An iterable of keys to include in the new map. ### Request Example ```dart final myMap = {'a': 1, 'b': 2, 'c': 3}; final newMap = myMap.take(['a', 'c']); ``` ### Response #### Success Response - Returns a new `Map` containing only the specified keys. #### Response Example ```dart {'a': 1, 'c': 3} ``` ``` -------------------------------- ### Asynchronous Operations with postDelayed Source: https://github.com/birjuvachhani/screwdriver/blob/main/example/example.md Demonstrates scheduling a function to run after a specified delay using `postDelayed` for asynchronous operations. ```dart postDelayed(2000,(){ print('after 2 seconds'); }); ``` -------------------------------- ### Iterating Over Map Entries Source: https://github.com/birjuvachhani/screwdriver/blob/main/example/example.md Demonstrates iterating over map entries using the `.records` extension, which provides key-value pairs as records for easier destructuring. ```dart final Map map = { 'name': 'John', 'age': 24, }; for(final (key, value) in map.records) { print('$key: $value'); } ``` -------------------------------- ### exceptAll Source: https://github.com/birjuvachhani/screwdriver/blob/main/EXTENSIONS.md Alias for subtract. ```APIDOC ## exceptAll ### Description Alias for `subtract`. ### Method METHOD ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **result** (Iterable) - The result of the subtraction. #### Response Example None ``` -------------------------------- ### Double and Boolean Utility Methods Source: https://github.com/birjuvachhani/screwdriver/blob/main/example/example.md Demonstrates utility methods for `double` to check if it's a whole number and for `bool` to toggle its value or convert it to an integer. ```dart randomDouble(max: 50); ``` ```dart 56.0.isWhole; ``` ```dart true.toggled; ``` ```dart false.toInt(); ``` -------------------------------- ### runCaching Source: https://github.com/birjuvachhani/screwdriver/blob/main/EXTENSIONS.md Executes a provided action and handles potential errors. ```APIDOC ## runCaching ### Description Executes a provided action and handles potential errors. ### Parameters - **action** (Function) - The action to execute. ``` -------------------------------- ### debounce Source: https://github.com/birjuvachhani/screwdriver/blob/main/EXTENSIONS.md Helper function to debounce `action` calls using a global `deBouncer` instance. If `immediateFirstRun` is set to true, it will run the `action` immediately for the first call and then wait for `duration` to run the next call if there's any. ```APIDOC ## debounce ### Description Helper function to debounce `action` calls using a global `deBouncer` instance. If `immediateFirstRun` is set to true, it will run the `action` immediately for the first call and then wait for `duration` to run the next call if there's any. ### Parameters - **action** (Function) - The function to debounce. - **duration** (Duration) - The duration to wait before allowing the action to be called again. - **immediateFirstRun** (bool, optional) - Whether to execute the action immediately on the first call. Defaults to false. ``` -------------------------------- ### << Source: https://github.com/birjuvachhani/screwdriver/blob/main/EXTENSIONS.md Allows adding a MapEntry to the map. ```APIDOC ## << ### Description Allows to add `MapEntry` to `this` map. ### Method METHOD ### Endpoint N/A (Instance method on Map) ### Parameters - `entry` (MapEntry) - The `MapEntry` to add. ### Request Example ```dart final myMap = {'a': 1}; myMap << MapEntry('b', 2); ``` ### Response #### Success Response - The map is modified in place with the new entry. #### Response Example ```dart {'a': 1, 'b': 2} ``` ``` -------------------------------- ### DateTime Comparison Methods Source: https://github.com/birjuvachhani/screwdriver/blob/main/EXTENSIONS.md Methods for comparing two DateTime instances. ```APIDOC ## DateTime Comparison Methods ### Description Methods for comparing two DateTime instances. ### Methods - **< (isBefore)**: Returns true if `this` occurs before `other`. - **> (isAfter)**: Returns true if `this` occurs after `other`. - **<= (isBeforeOrSame)**: Returns true if `this` occurs before or at the same moment as `other`. - **>= (isAfterOrSame)**: Returns true if `this` occurs after or at the same moment as `other`. - **isBeforeDate(DateTime other)**: Returns true if the date of `this` occurs before the date of `other`. - **isSameOrBeforeDate(DateTime other)**: Returns true if the date of `this` occurs on the same day as the date of `other` or before it. - **isAfterDate(DateTime other)**: Returns true if the date of `this` occurs after the date of `other`. - **isSameOrAfterDate(DateTime other)**: Returns true if the date of `this` occurs on the same day as the date of `other` or after it. - **isSameDateAs(DateTime other)**: Returns true if the date of `this` occurs on the same day as the date of `other`. - **isBetween(DateTime date1, DateTime date2)**: Returns true if `this` falls between `date1` and `date2` irrespective of the order in the Calender. ``` -------------------------------- ### Utility Functions and Extensions Source: https://github.com/birjuvachhani/screwdriver/blob/main/README.md Includes various utility functions and extensions such as assertion checks, caching wrappers, TODO annotations, Triple data structure, and conditional object transformations (takeIf, takeUnless). ```dart check(divider != 0); runCaching((){ count / 0; }); TODO('find a way to implement this properly'); // throws UnimplementedError on invocation Triple(45,true, 'Hello World'); user.takeIf((u) => u.age > 18)?.allowAccess(); person.takeUnless((p) => p > 18)?.areTeenagers(); final DateTime date = tomorrow; yesterday.isInDecember; ``` -------------------------------- ### DateTime and Duration Extensions Source: https://github.com/birjuvachhani/screwdriver/blob/main/example/example.md Showcases extension methods for `DateTime` and `Duration` to easily check days of the week, calculate past dates, create durations, and compare time intervals. ```dart now().isMonday; ``` ```dart final DateTime fiveDaysAgo = 5.daysAgo; ``` ```dart final Duration nineMinutes = 9.minutes; ``` ```dart 45.minutes.isInHours; ``` ```dart 15.daysAgo < 5.days.ago; ``` ```dart 20.minutes.ago >= 50.minutes.ago; ``` ```dart now().previousDay; ``` ```dart 10.days.ago.isBetween(15.days.ago, now()); ``` -------------------------------- ### postDelayed Source: https://github.com/birjuvachhani/screwdriver/blob/main/EXTENSIONS.md Runs a given action after a delay of `millis`, no sooner than in the next event-loop iteration, after all micro-tasks have run. ```APIDOC ## postDelayed ### Description Runs a given action after a delay of `millis`, no sooner than in the next event-loop iteration, after all micro-tasks have run. ### Parameters - **action** (Function) - The function to execute. - **millis** (int) - The delay in milliseconds. ``` -------------------------------- ### except Source: https://github.com/birjuvachhani/screwdriver/blob/main/EXTENSIONS.md Alias for subtract. ```APIDOC ## except ### Description Alias for `subtract`. ### Method METHOD ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **result** (Iterable) - The result of the subtraction. #### Response Example None ``` -------------------------------- ### Screwdriver Project License Source: https://github.com/birjuvachhani/screwdriver/blob/main/README.md This is the full license text for the Screwdriver project. It details the terms for redistribution and use of the software. ```plaintext Copyright (c) 2020, Birju Vachhani All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ``` -------------------------------- ### Directory Extensions Source: https://github.com/birjuvachhani/screwdriver/blob/main/EXTENSIONS.md Provides utility extensions for Directory objects for file and directory manipulation. ```APIDOC ## METHOD file ### Description Creates a `File` instance with the given `fileName` in this directory. ### Method METHOD ### Endpoint Directory.file(String fileName) ### Parameters #### Path Parameters - **fileName** (string) - Required - The name of the file to create. ### Response #### Success Response (File) - **File**: A File instance representing the file in this directory. ## METHOD subDir ### Description Creates a `Directory` instance representing a subdirectory in this directory. ### Method METHOD ### Endpoint Directory.subDir(String dirName) ### Parameters #### Path Parameters - **dirName** (string) - Required - The name of the subdirectory to create. ### Response #### Success Response (Directory) - **Directory**: A Directory instance representing the subdirectory. ## METHOD deleteIfExists ### Description Deletes the directory and its contents if it exists. ### Method METHOD ### Endpoint Directory.deleteIfExists() ### Parameters None ### Response #### Success Response (void) - **void**: This method does not return a value. ## METHOD deleteIfExistsSync ### Description Synchronously deletes the directory and its contents if it exists. ### Method METHOD ### Endpoint Directory.deleteIfExistsSync() ### Parameters None ### Response #### Success Response (void) - **void**: This method does not return a value. ## METHOD createIfMissing ### Description Creates the directory if it does not exist. Returns the directory instance. ### Method METHOD ### Endpoint Directory.createIfMissing() ### Parameters None ### Response #### Success Response (Directory) - **Directory**: The directory instance, created if it did not exist. ## METHOD createIfMissingSync ### Description Synchronously creates the directory if it does not exist. ### Method METHOD ### Endpoint Directory.createIfMissingSync() ### Parameters None ### Response #### Success Response (void) - **void**: This method does not return a value. ``` -------------------------------- ### or Source: https://github.com/birjuvachhani/screwdriver/blob/main/EXTENSIONS.md Returns this or `value` if null. Useful for equations. ```APIDOC ## METHOD or ### Description Returns this or `value` if null. Useful for equations. ### Method METHOD ### Endpoint N/A ### Parameters #### Query Parameters - **value** (any) - Required - The value to return if this is null. ### Request Example N/A ### Response #### Success Response (200) - **result** (any) - This value or the provided `value` if this is null. ### Response Example N/A ``` -------------------------------- ### all Source: https://github.com/birjuvachhani/screwdriver/blob/main/EXTENSIONS.md Alias for `Iterable.every`. ```APIDOC ## all ### Description Alias for `Iterable.every`. Returns true if all elements of this iterable satisfy the predicate. ### Method METHOD ### Endpoint N/A (Method on Iterable) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **predicate** (Function) - The function to test each element. ``` -------------------------------- ### String Extensions Source: https://github.com/birjuvachhani/screwdriver/blob/main/EXTENSIONS.md Provides utility extensions for String objects to check for null, empty, blank, or content, and to provide default values. ```APIDOC ## GETTER isNullOrEmpty ### Description Returns true if the string is either null or an empty string. ### Method GETTER ### Endpoint String.isNullOrEmpty ### Parameters None ### Response #### Success Response (true/false) - **bool**: true if the string is null or empty, false otherwise. ## GETTER isNotNullOrEmpty ### Description Returns true if the string is neither null nor an empty string. ### Method GETTER ### Endpoint String.isNotNullOrEmpty ### Parameters None ### Response #### Success Response (true/false) - **bool**: true if the string is not null and not empty, false otherwise. ## GETTER isNullOrBlank ### Description Returns true if the string is either null or a blank string (contains only whitespace). ### Method GETTER ### Endpoint String.isNullOrBlank ### Parameters None ### Response #### Success Response (true/false) - **bool**: true if the string is null or blank, false otherwise. ## GETTER isNotNullOrBlank ### Description Returns true if the string is neither null nor a blank string. ### Method GETTER ### Endpoint String.isNotNullOrBlank ### Parameters None ### Response #### Success Response (true/false) - **bool**: true if the string is not null and not blank, false otherwise. ## GETTER hasContent ### Description Alias for `isNotNullOrEmpty`. Returns true if the string is neither null nor an empty string. ### Method GETTER ### Endpoint String.hasContent ### Parameters None ### Response #### Success Response (true/false) - **bool**: true if the string is not null and not empty, false otherwise. ## GETTER orEmpty ### Description Returns the string if it is not null, otherwise returns an empty string. ### Method GETTER ### Endpoint String.orEmpty ### Parameters None ### Response #### Success Response (string) - **string**: The original string if not null, otherwise an empty string. ## METHOD matchesExactly ### Description Returns true if this string exactly matches the given pattern. ### Method METHOD ### Endpoint String.matchesExactly(String pattern) ### Parameters #### Path Parameters - **pattern** (string) - Required - The pattern to match against. ### Response #### Success Response (true/false) - **bool**: true if the string exactly matches the pattern, false otherwise. ``` -------------------------------- ### associateBy Source: https://github.com/birjuvachhani/screwdriver/blob/main/EXTENSIONS.md Returns a `Map` containing the elements from the given List indexed by the key returned from `keySelector` function applied to each element. ```APIDOC ## associateBy ### Description Returns a `Map` containing the elements from the given iterable indexed by the key returned from the `keySelector` function applied to each element. ### Method METHOD ### Endpoint N/A (Method on Iterable) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **keySelector** (Function) - A function that returns the key for each element. ``` -------------------------------- ### complete Source: https://github.com/birjuvachhani/screwdriver/blob/main/EXTENSIONS.md Waits for the given `action` to complete and returns the result. This is useful when an async operation doesn't support async/await and you have to use a callback-based approach that requires you to utilize a completer. This function helps you to avoid writing boilerplate code for creating a completer and returning its future. ```APIDOC ## complete ### Description Waits for the given `action` to complete and returns the result. This is useful when an async operation doesn't support async/await and you have to use a callback-based approach that requires you to utilize a completer. This function helps you to avoid writing boilerplate code for creating a completer and returning its future. ### Parameters - **action** (Function) - The asynchronous action to complete. ``` -------------------------------- ### unwrap Source: https://github.com/birjuvachhani/screwdriver/blob/main/EXTENSIONS.md Unwraps the string by removing a prefix and suffix. Uses prefix as suffix if suffix is null. ```APIDOC ## unwrap ### Description Unwraps the string by removing a prefix and suffix. Uses the prefix as the suffix if the suffix is null. ### Method METHOD ### Endpoint String.unwrap(String prefix, [String? suffix]) ### Example ```dart '*hello*'.unwrap("*"); // returns hello ``.unwrap('<','>'); // returns html ``` ``` -------------------------------- ### minutesAfter Source: https://github.com/birjuvachhani/screwdriver/blob/main/EXTENSIONS.md Calculates the `DateTime` that will be a specified number of minutes after the current time. ```APIDOC ## GETTER minutesAfter ### Description Returns `DateTime` with time that is `this` minutes after. ### Method GETTER ### Endpoint N/A (Instance Getter) ### Parameters None ### Response #### Success Response (DateTime) - Returns a `DateTime` object representing the time `this` minutes after. ``` -------------------------------- ### orZero Source: https://github.com/birjuvachhani/screwdriver/blob/main/EXTENSIONS.md Returns this value or 0 if null. Useful for equations. ```APIDOC ## GETTER orZero ### Description Returns this value or 0 if null. Useful for equations. ### Method GETTER ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response #### Success Response (200) - **value** (number) - This value or 0 if it is null. ### Response Example N/A ``` -------------------------------- ### associateTo Source: https://github.com/birjuvachhani/screwdriver/blob/main/EXTENSIONS.md Populates and returns the `destination` map with key-value pairs provided by `transform` function applied to each element of the given iterable. ```APIDOC ## associateTo ### Description Populates and returns the `destination` map with key-value pairs provided by the `transform` function applied to each element of the given iterable. ### Method METHOD ### Endpoint N/A (Method on Iterable) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **destination** (Map) - The map to populate. - **transform** (Function) - A function that returns a key-value pair for each element. ``` -------------------------------- ### Iterable Extensions Source: https://github.com/birjuvachhani/screwdriver/blob/main/EXTENSIONS.md Extensions for Iterable? to check for null or empty states. ```APIDOC ## isNullOrEmpty ### Description Returns true if the iterable is either null or empty. ### Type GETTER ### Example ```dart Iterable? list; print(list.isNullOrEmpty); // true list = []; print(list.isNullOrEmpty); // true list = [1, 2]; print(list.isNullOrEmpty); // false ``` ``` ```APIDOC ## isBlank ### Description Alias for `isNullOrEmpty`. Returns true if the iterable is either null or empty. ### Type GETTER ### Example ```dart Iterable? list; print(list.isBlank); // true list = []; print(list.isBlank); // true list = [1, 2]; print(list.isBlank); // false ``` ``` ```APIDOC ## isNotBlank ### Description Alias for `isNotNullOrEmpty`. Returns true if the iterable is neither null nor empty. ### Type GETTER ### Example ```dart Iterable? list; print(list.isNotBlank); // false list = []; print(list.isNotBlank); // false list = [1, 2]; print(list.isNotBlank); // true ``` ``` ```APIDOC ## isNotNullOrEmpty ### Description Returns true if the iterable is neither null nor empty. ### Type GETTER ### Example ```dart Iterable? list; print(list.isNotNullOrEmpty); // false list = []; print(list.isNotNullOrEmpty); // false list = [1, 2]; print(list.isNotNullOrEmpty); // true ``` ``` -------------------------------- ### Import Screwdriver Library Source: https://github.com/birjuvachhani/screwdriver/blob/main/README.md Import the main Screwdriver library into your Dart code to access its extensions and helper functions. ```dart import 'package:screwdriver/screwdriver.dart'; ``` -------------------------------- ### reversed Source: https://github.com/birjuvachhani/screwdriver/blob/main/EXTENSIONS.md Returns a reversed version of the string. ```APIDOC ## reversed ### Description Returns a reversed string of the original string. ### Method GETTER ### Endpoint String.reversed ``` -------------------------------- ### Collection Manipulation Extensions Source: https://github.com/birjuvachhani/screwdriver/blob/main/example/example.md Showcases various extension methods for collections like lists and maps, including appending, retrieving first or null, dropping elements, taking last elements, checking conditions, grouping, counting, random selection, finding max by, intersection, and adding pairs. ```dart users << User(name: 'John'); ``` ```dart users.firstOrNull; ``` ```dart users.drop(5); ``` ```dart users.takeLast(3); ``` ```dart user.all((u) => u.age > 18); ``` ```dart cars.groupBy((car) => car.color); ``` ```dart cars.count((car) => car.isPorsche); ``` ```dart cars.random(); ``` ```dart cars.maxBy((car) => car.price); ``` ```dart cars.intersect(otherCars); ``` ```dart {'name': 'John'} << Pair('email','john@doe.com'); ``` -------------------------------- ### drop Source: https://github.com/birjuvachhani/screwdriver/blob/main/EXTENSIONS.md Alias for `Iterable.skip`. ```APIDOC ## drop ### Description Alias for `Iterable.skip`. Skips the first `n` elements of the iterable. ### Method METHOD ### Endpoint N/A (Method on Iterable) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **n** (int) - The number of elements to skip. ``` -------------------------------- ### associateByTo Source: https://github.com/birjuvachhani/screwdriver/blob/main/EXTENSIONS.md Populates and returns the `destination` mutable map with key-value pairs, where key is provided by the `keySelector` function applied to each element of the given iterable and value is the element itself. ```APIDOC ## associateByTo ### Description Populates and returns the `destination` mutable map with key-value pairs, where the key is provided by the `keySelector` function applied to each element of the given iterable and the value is the element itself. ### Method METHOD ### Endpoint N/A (Method on Iterable) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **destination** (MutableMap) - The mutable map to populate. - **keySelector** (Function) - A function that returns the key for each element. ``` -------------------------------- ### min Source: https://github.com/birjuvachhani/screwdriver/blob/main/EXTENSIONS.md Returns `lowerBound` if this value is less than or equal to `lowerBound`, Otherwise returns this value. ```APIDOC ## METHOD min ### Description Returns `lowerBound` if this value is less than or equal to `lowerBound`, Otherwise returns this value. ### Method METHOD ### Endpoint N/A ### Parameters #### Query Parameters - **lowerBound** (number) - Required - The lower bound to compare against. ### Request Example N/A ### Response #### Success Response (200) - **result** (number) - The value, or `lowerBound` if the value is less than or equal to it. ### Response Example N/A ``` -------------------------------- ### require Source: https://github.com/birjuvachhani/screwdriver/blob/main/EXTENSIONS.md Throws `IllegalArgumentException` if `value` is false. If `message` is supplied, it is used as the error message. ```APIDOC ## require ### Description Throws `IllegalArgumentException` if `value` is false. If `message` is supplied, it is used as the error message. ### Parameters - **value** (bool) - The boolean value to check. - **message** (String, optional) - The error message to use if the value is false. ``` -------------------------------- ### check Source: https://github.com/birjuvachhani/screwdriver/blob/main/EXTENSIONS.md Throws `IllegalStateException` if `value` is false. ```APIDOC ## check ### Description Throws `IllegalStateException` if `value` is false. ### Parameters - **value** (bool) - The boolean value to check. - **message** (String, optional) - The error message to throw if the value is false. ``` -------------------------------- ### toIntOrNull Source: https://github.com/birjuvachhani/screwdriver/blob/main/EXTENSIONS.md Returns the string as an integer or null. Radix must be between 2 and 36. ```APIDOC ## toIntOrNull ### Description Returns the string as an integer or null. Radix must be between 2..36. ### Method METHOD ### Endpoint String.toIntOrNull(int radix) ``` -------------------------------- ### associateWithTo Source: https://github.com/birjuvachhani/screwdriver/blob/main/EXTENSIONS.md Populates and returns the destination map with key-value pairs for each element of the given iterable. The key is the element itself, and the value is provided by the valueSelector function applied to that key. ```APIDOC ## associateWithTo ### Description Populates and returns the `destination` map with key-value pairs for each element of the given iterable, where key is the element itself and value is provided by the `valueSelector` function applied to that key. ### Method METHOD ### Endpoint N/A (Extension Method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) Returns the populated destination map. #### Response Example None ``` -------------------------------- ### String Manipulation with Screwdriver Source: https://github.com/birjuvachhani/screwdriver/blob/main/example/example.md Utilize extension methods for common string operations like capitalization, checking for blankness, type conversion, wrapping, binary checks, email validation, reversing, word splitting, JSON parsing, and prefix removal. ```dart 'hello'.capitalized; ``` ```dart ' '.isBlankl ``` ```dart '45'.toIntOrNull(); ``` ```dart 'html'.wrap('<','>'); ``` ```dart '1010111010001'.isBinary; ``` ```dart 'test@example.com'.isEmail; ``` ```dart 'abcd'.reversed; ``` ```dart 'This is a test'.words; ``` ```dart '{"name":"John"}'.parseJson(); ``` ```dart '#hello'.removePrefix('#'); ``` -------------------------------- ### List Extensions Source: https://github.com/birjuvachhani/screwdriver/blob/main/EXTENSIONS.md Extensions for List to convert to different formats or encodings. ```APIDOC ## toBase64 ### Description Converts the list of integers to a base64 encoded string. e.g. converting bytes to base64 string. ### Type METHOD ### Example ```dart final bytes = [72, 101, 108, 108, 111]; // ASCII for 'Hello' final base64String = bytes.toBase64(); print(base64String); // SGVsbG8= ``` ``` ```APIDOC ## toUint8List ### Description Converts this list of integers to a `Uint8List`. ### Type METHOD ### Example ```dart final intList = [72, 101, 108, 108, 111]; final uint8List = intList.toUint8List(); print(uint8List); // Uint8List(5) [72, 101, 108, 108, 111] ``` ``` ```APIDOC ## toUint16List ### Description Converts this list of integers to a `Uint16List`. ### Type METHOD ### Example ```dart final intList = [256, 512, 768]; final uint16List = intList.toUint16List(); print(uint16List); // Uint16List(3) [256, 512, 768] ``` ``` -------------------------------- ### dropLast Source: https://github.com/birjuvachhani/screwdriver/blob/main/EXTENSIONS.md Alias for `Iterable.skip`. ```APIDOC ## dropLast ### Description Alias for `Iterable.skip`. This seems to be a documentation error as `dropLast` typically removes elements from the end. Assuming it's intended to be `Iterable.skipLast`. ### Method METHOD ### Endpoint N/A (Method on Iterable) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **n** (int) - The number of elements to drop from the end. ``` -------------------------------- ### Add Screwdriver Dependency Source: https://github.com/birjuvachhani/screwdriver/blob/main/README.md Add the Screwdriver package as a dependency in your project's pubspec.yaml file. No need to add 'collection' separately as it's included. ```yaml dependencies: screwdriver: ``` -------------------------------- ### Double and Bool Extensions Source: https://github.com/birjuvachhani/screwdriver/blob/main/README.md Showcases extensions for Double and Bool types, including generating random doubles, checking if a double is a whole number, toggling boolean values, and converting booleans to integers. ```dart randomDouble(max: 50); // random double value between 0 and 50 56.0.isWhole; // true true.toggled; // false false.toInt(); // 0 ``` -------------------------------- ### tryCatch Source: https://github.com/birjuvachhani/screwdriver/blob/main/EXTENSIONS.md Safely executes an asynchronous operation and catches any error. ```APIDOC ## tryCatch ### Description Safely executes an asynchronous operation and catches any error. ### Parameters - **action** (Function) - The asynchronous operation to execute. - **onError** (Function) - The callback function to handle any error. ``` -------------------------------- ### takeLast Source: https://github.com/birjuvachhani/screwdriver/blob/main/EXTENSIONS.md Alias for `Iterable.skip`. ```APIDOC ## takeLast ### Description Alias for `Iterable.skip`. This seems to be a documentation error as `takeLast` typically returns the last `n` elements. Assuming it's intended to be `Iterable.takeLast`. ### Method METHOD ### Endpoint N/A (Method on Iterable) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **n** (int) - The number of elements to take from the end. ``` -------------------------------- ### words Source: https://github.com/birjuvachhani/screwdriver/blob/main/EXTENSIONS.md Tokenizes the string into words by breaking it with spaces. ```APIDOC ## words ### Description Tokenizes the string into words by breaking it with spaces. ### Method GETTER ### Endpoint String.words ``` -------------------------------- ### where Source: https://github.com/birjuvachhani/screwdriver/blob/main/EXTENSIONS.md Returns a new Map containing entries that satisfy the given test function, which operates on both the key and value. ```APIDOC ## where ### Description Returns a new `Map` with the same keys and values as `this` where the key-value pair satisfies the `test` function. Similar to `Iterable.where`. ### Method METHOD ### Endpoint N/A (Instance method on Map) ### Parameters - `test` (bool Function(K, V)) - A function that returns true if the key-value pair should be included. ### Request Example ```dart final myMap = {'a': 1, 'b': 2, 'c': 3}; final filteredMap = myMap.where((key, value) => value > 1); ``` ### Response #### Success Response - Returns a new `Map` containing entries that satisfy the test function. #### Response Example ```dart {'b': 2, 'c': 3} ``` ``` -------------------------------- ### orNullIfBlank Source: https://github.com/birjuvachhani/screwdriver/blob/main/EXTENSIONS.md Returns the string if it is not blank, otherwise returns null. ```APIDOC ## orNullIfBlank ### Description Returns the string if it is not blank, otherwise returns null. ### Method GETTER ### Endpoint String.orNullIfBlank ``` -------------------------------- ### toggledCase Source: https://github.com/birjuvachhani/screwdriver/blob/main/EXTENSIONS.md Toggles the case of the characters in the string. ```APIDOC ## toggledCase ### Description Toggles the case of the characters in the string. ### Method GETTER ### Endpoint String.toggledCase ``` -------------------------------- ### onEach Source: https://github.com/birjuvachhani/screwdriver/blob/main/EXTENSIONS.md Performs the given action on each element and returns the iterable itself afterwards. ```APIDOC ## onEach ### Description Performs the given `action` on each element and returns the iterable itself afterwards. ### Method METHOD ### Endpoint N/A (Extension Method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) Returns the original iterable after performing the action on each element. #### Response Example None ``` -------------------------------- ### count Source: https://github.com/birjuvachhani/screwdriver/blob/main/EXTENSIONS.md Returns the number of elements matching the given predicate. ```APIDOC ## count ### Description Returns the number of elements matching the given `predicate`. ### Method METHOD ### Endpoint N/A (Extension Method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) Returns the count of elements that satisfy the predicate. #### Response Example None ``` -------------------------------- ### findAllBy Source: https://github.com/birjuvachhani/screwdriver/blob/main/EXTENSIONS.md Finds all elements where the result of selector matches the query. Returns empty collection if no element is found. ```APIDOC ## findAllBy ### Description Finds all elements where the result of `selector` matches the `query`. Returns empty collection if no element is found. ### Method METHOD ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **elements** (Iterable) - A collection of elements matching the query. #### Response Example None ```