gits_extension

Last updated:

0 purchases

gits_extension Image
gits_extension Images
Add to Cart

Description:

gits extension

Gits Extension #
Fork and modify from dartx and export package time.
Scope Functions #
.run #
Calls the specified function [block] with [it] value as its receiver and returns its result.
String? getValue() => '1';
final value = getValue();

value?.run((it) => doSomething(it));
copied to clipboard
.let #
Calls the specified function [block] with [it] value as its argument and returns its result.
String? getValue() => '1';
final value = getValue();
final let = value?.let((it) => int.parse(it)); // 1 (int)
copied to clipboard
.also #
Calls the specified function [block] with [it] value as its argument and returns block value.
String? getValue() => '1';
final value = getValue();
int itValue = 0;
final also = value?.also((it) {
itValue = int.parse(it);
});

print(also); // 1 (String)
print(itValue); // 1 (int)
copied to clipboard
.takeIf #
Returns [T] value if it satisfies the given [predicate] or null, if it doesn't.
final a = 10.takeIf((it) => it % 2 == 0); // 10
final b = 9.takeIf((it) => it % 2 == 0); // null
copied to clipboard
.takeUnless #
Returns [T] value if it does not satisfy the given [predicate] or null, if it does.
final value = 10.takeUnless((it) => it % 2 == 0); // null
final value = 9.takeUnless((it) => it % 2 == 0); // 9
copied to clipboard
int #
.plus #
Return int this plus with [value].
final a = 1.plus(1); // 2
final b = 200.plus(50); // 250
copied to clipboard
.minus #
Return int this minus with [value].
final a = 1.minus(1); // 0
final b = 200.minus(50); // 150
copied to clipboard
.ordinal #
Returns an ordinal number of String type for any integer
final a = 1.ordinal(); // 1st
final b = 108.ordinal(); // 108th
copied to clipboard
double #
.plus #
Return double this plus with [value].
final a = 1.0.plus(1.5); // 2.5
final b = 200.5.plus(50.5); // 251.0
copied to clipboard
.minus #
Return double this minus with [value].
final a = 1.5.minus(1.0); // 0.5
final b = 200.5.minus(50.5); // 150
copied to clipboard
String #
.isEmail #
Return boolean checks whether the String is a valid email.
final isEmail = '[email protected]'.isEmail; // true
final isNotEmail = 'example@'.isEmail; // false
copied to clipboard
.capitalize #
Returns a copy of the string having its first letter uppercased, or the original string, if it's empty or already starts with an upper case letter.
final word = 'abcd'.capitalize(); // Abcd
final anotherWord = 'Abcd'.capitalize(); // Abcd
copied to clipboard
.decapitalize #
Returns a copy of the string having its first letter lowercased, or the original string, if it's empty or already starts with a lower case letter.
final word = 'abcd'.decapitalize(); // abcd
final anotherWord = 'Abcd'.decapitalize(); // abcd
copied to clipboard
.isBlank #
Returns true if this string is empty or consists solely of whitespace characters.
final notBlank = ' .'.isBlank; // false
final blank = ' '.isBlank; // true
copied to clipboard
.isDouble #
Returns true if the string can be parsed as a double.
final a = ''.isDouble; // false
final b = 'a'.isDouble; // false
final c = '1'.isDouble; // true
final d = '1.0'.isDouble; // true
final e = '123456789.987654321'.isDouble; // true
final f = '1,000'.isDouble; // false
copied to clipboard
.isInt #
Returns true if the string can be parsed as an integer.
final a = ''.isInt; // false
final b = 'a'.isInt; // false
final c = '1'.isInt; // true
final d = '1.0'.isInt; // false
final e = '1,000'.isInt; // false
copied to clipboard
.isLowerCase #
Returns true if the entire string is lower case.
final a = 'abc'.isLowerCase; // true
final b = 'abC'.isLowerCase; // false
final c = ' '.isLowerCase; // true
final d = ''.isLowerCase; // false
copied to clipboard
.isNotBlank #
Returns true if this string is not empty and contains characters except whitespace characters.
final blank = ' '.isNotBlank; // false
final notBlank = ' .'.isNotBlank; // true
copied to clipboard
.isNullOrEmpty #
Returns true if the String is either null or empty.
final isNull = null.isNullOrEmpty; // true
final isEmpty = ''.isNullOrEmpty; // true
final isBlank = ' '.isNullOrEmpty; // false
final isLineBreak = '\n'.isNullOrEmpty; // false
copied to clipboard
.isNotNullOrEmpty #
Returns true if the String is neither null nor empty.
final isNull = null.isNullOrEmpty; // true
final isEmpty = ''.isNullOrEmpty; // true
final isBlank = ' '.isNullOrEmpty; // false
final isLineBreak = '\n'.isNullOrEmpty; // false
copied to clipboard
.isNullOrBlank #
Returns true if the String is either null or blank.
final isNull = null.isNullOrBlank; // true
final isEmpty = ''.isNullOrBlank; // true
final isBlank = ' '.isNullOrBlank; // true
final isLineBreak = '\n'.isNullOrBlank; // true
final isFoo = ' foo '.isNullOrBlank; // false
copied to clipboard
.isNotNullOrBlank #
Returns true if the String is neither null nor blank.
final isNull = null.isNullOrBlank; // true
final isEmpty = ''.isNullOrBlank; // true
final isBlank = ' '.isNullOrBlank; // true
final isLineBreak = '\n'.isNullOrBlank; // true
final isFoo = ' foo '.isNullOrBlank; // true
copied to clipboard
.isUpperCase #
Returns true if the entire string is upper case.
final a = 'ABC'.isUpperCase; // true
final b = 'ABc'.isUpperCase; // false
final c = ' '.isUpperCase; // true
final d = ''.isUpperCase; // false
copied to clipboard
.urlEncode #
Translates a string into application/x-www-form-urlencoded format using a specific encoding scheme.
const originalUrl = 'Hello Ladies + Gentlemen, a signed OAuth request!';
final encodedUrl = originalUrl.urlEncode;
// 'Hello%20Ladies%20+%20Gentlemen,%20a%20signed%20OAuth%20request!'
copied to clipboard
.urlDecode #
Decodes an application/x-www-form-urlencoded string using a specific encoding scheme.
const encodedUrl = 'Hello%20Ladies%20+%20Gentlemen,%20a%20signed%20OAuth%20request!';
final decodedUrl = encodingUrl.urlDecode;
// 'Hello Ladies + Gentlemen, a signed OAuth request!'
copied to clipboard
.slice() #
Returns a new substring containing all characters including indices [start] and [end].
If [end] is omitted, it is being set to lastIndex.
final sliceOne = 'awesomeString'.slice(0,6)); // awesome
final sliceTwo = 'awesomeString'.slice(7)); // String
copied to clipboard
.toDoubleOrNull() #
Parses the string as a double and returns the result or null if the String is not a valid representation of a number.
final numOne = '1'.toDoubleOrNull(); // 1.0
final numTwo = '1.2'.toDoubleOrNull(); // 1.2
final blank = ''.toDoubleOrNull(); // null
copied to clipboard
.toInt() #
Parses the string as an integer and returns the result. The radix (base) thereby defaults to 10. Throws a FormatException if parsing fails.
final a = '1'.toInt(); // 1
final b = '100'.toInt(radix: 2); // 4
final c = '100'.toInt(radix: 16); // 256
final d = '1.0'.toInt(); // throws FormatException
copied to clipboard
.toIntOrNull() #
Parses the string as an integer or returns null if it is not a number.
final number = '12345'.toIntOrNull(); // 12345
final notANumber = '123-45'.toIntOrNull(); // null
copied to clipboard
.toUtf8() #
Converts String to UTF-8 encoding.
final emptyString = ''.toUtf8(); // []
final hi = 'hi'.toUtf8(); // [104, 105]
final emoji = '😄'.toUtf8(); // [240, 159, 152, 132]

copied to clipboard
.toUtf16() #
Converts String to UTF-16 encoding.
final emptyString = ''.toUtf16(); // []
final hi = 'hi'.toUtf16(); // [104, 105]
final emoji = '😄'.toUtf16(); // [55357, 56836]
copied to clipboard
.orEmpty() #
Returns the string if it is not null, or the empty string otherwise.
String? nullableStr;
final str = nullableStr.orEmpty(); // ''
copied to clipboard
.matches() #
Returns true if this char sequence matches the given regular expression.
print('as'.matches(RegExp('^.s\$'))) // true
print('mst'.matches(RegExp('^.s\$'))) // false
copied to clipboard
Iterable Num #
.sum #
Return int this plus with [value].
final a = [50, 10, 40].sum(); // 100
copied to clipboard
.average #
Return int this plus with [value].
final a = [50, 10].average(); // 30.0
copied to clipboard
.median #
Return int this plus with [value].
final a = [1, 2, 3, 4, 5].median(); // 3
final b = [5, 4, 3, 2, 1].median(); // 3
copied to clipboard
Time utils #
Gits extension exports @jogboms great ⏰ time.dart package so you can do the following:
int secondsInADay = 1.days.inSeconds;

Duration totalTime = [12.5.seconds, 101.milliseconds, 2.5.minutes].sum();

DateTime oneWeekLater = DateTime.now() + 1.week;
copied to clipboard
Check out ⏰ time.dart for more information and examples.

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.