dart_extensionz 6.3.5
dart_extensionz: ^6.3.5 copied to clipboard
A set of Dart extensions I use in various projects. Including Boolean, DateTime extensions and more.
Dart Extensionz #
A set of Dart extensions I use in various projects.
Usage #
Booleans #
- To Int
bool value = false;
int result = value.toInt();
expect(result, 0);
copied to clipboard
DateTimes #
- Is Leap Year
DateTime value = DateTime(2020);
bool result = value.isLeapYear;
expect(result, true);
copied to clipboard
Durations #
- Getters
Duration value = Duration(days: 1, hours: 5, minutes: 10);
expect(value.days, 1);
expect(value.hours, 5);
expect(value.minutes: 10);
copied to clipboard
Integers #
- Ordinal
int value = 12;
String result = value.ordinal;
expect(result, '12th');
copied to clipboard
Strings #
- Normalize Space
String value = ' Jon Snow ';
String result = value.normalizeSpace();
expect(result, 'Jon Snow');
copied to clipboard
- Mask
String value = 'Testing';
expect(value.mask(), '####ing');
expect(value.mask(end: value.length, char: '*'), '*******');
copied to clipboard
Files #
File file = File('/documents/MyAwesomeFile.txt');
expect(file.name, 'MyAwesomeFile.txt');
expect(file.displayName, 'MyAwesomeFile');
expect(file.extension, 'txt');
copied to clipboard
Uris #
Uri value = Uri(host: 'google.com');
value.addPath('search');
value.addQuery('q', 'test');
copied to clipboard
- The generated documentation will give you a great overview of all that is available.