saropa_dart_utils 0.5.9 copy "saropa_dart_utils: ^0.5.9" to clipboard
saropa_dart_utils: ^0.5.9 copied to clipboard

Boilerplate reduction tools and human-readable extension methods by Saropa

saropa company logo

Saropa Dart Utils #


Boilerplate reduction tools and human readable extension methods by Saropa

pub.dev linter: very good analysis style: very good analysis

slack: saropa Google Play: saropa AppStore: saropa

github home stars likes Open Issues Open PRs

We encourage your to review our public Code of Conduct.


34 extension classes providing 200+ utility methods | 1,000+ test cases ensuring reliability


Table of Contents #

Quick Start #

Add to your pubspec.yaml:

dependencies:
  saropa_dart_utils: ^0.5.7

Import the package:

import 'package:saropa_dart_utils/saropa_dart_utils.dart';

Extension Categories #

String Extensions #

Null Safety & Checking

String? text;
text.isNullOrEmpty; // true
text.notNullOrEmpty; // false

text = "Hello";
text.isNullOrEmpty; // false
"".isNumeric(); // false
"123".isNumeric(); // true

Case Manipulation

"hello world".titleCase(); // "Hello world"
"hello world".capitalizeWords(); // "Hello World"
"hello".upperCaseFirstChar(); // "Hello"
"HELLO".lowerCaseFirstChar(); // "hELLO"
"helloWorld".insertSpaceBetweenCapitalized(); // "hello World"

Wrapping & Formatting

"Saropa".wrapSingleQuotes(); // 'Saropa'
"Saropa".wrapDoubleQuotes(); // "Saropa"
"Saropa".wrapWith(before: "(", after: ")"); // (Saropa)
"Saropa".encloseInParentheses(); // (Saropa)

Truncation

"Very long text here".truncateWithEllipsis(10); // "Very long …"
"This is a long sentence".truncateWithEllipsisPreserveWords(15); // "This is a long…"

Cleaning & Removing

"www.saropa.com".removeStart("www."); // "saropa.com"
"saropa.com/".removeEnd("/"); // "saropa.com"
"  multiple   spaces  ".compressSpaces(); // "multiple spaces"
"abc123def".removeNonNumbers(); // "123"
"Hello!?".removePunctuation(); // "Hello"

Searching & Extracting

"hello world".isContainsWord("world"); // true
"test@example.com".between("@", "."); // "example"
"path/to/file".betweenLast("/", "."); // "file"
"get-everything-after".getEverythingAfter("-"); // "everything-after"

Pluralization & Grammar

"apple".pluralize(3); // "apples"
"box".pluralize(2); // "boxes"
"John".possess(); // "John's"
"apple".grammarArticle(); // "an"

Diacritics

"café".removeDiacritics(); // "cafe"
"café".containsDiacritics(); // true

DateTime Extensions #

Date Comparisons

DateTime date = DateTime(2024, 1, 1);
date.isToday(); // false
date.isBeforeNow(); // true
date.isAfterNow(); // false
date.isSameDateOnly(DateTime(2024, 1, 1, 12, 0)); // true
date.isBetween(DateTime(2023, 1, 1), DateTime(2025, 1, 1)); // true

Date Manipulation

DateTime date = DateTime(2024, 1, 15);
date.addYears(1); // 2025-01-15
date.addMonths(2); // 2024-03-15
date.addDays(10); // 2024-01-25
date.nextDay(); // 2024-01-16
date.prevDay(); // 2024-01-14

Age Calculation

DateTime birthDate = DateTime(1990, 5, 15);
birthDate.calculateAgeFromNow(); // Current age
birthDate.isUnder13(); // false

Date Ranges

DateTime start = DateTime(2024, 1, 1);
DateTimeRange range = DateTimeRange(start: start, end: start.addDays(30));
range.inRange(DateTime(2024, 1, 15)); // true

Date List Generation

DateTime.now().generateDayList(7); // List of next 7 days

List Extensions #

Comparison & Searching

[1, 2, 3].equalsIgnoringOrder([3, 2, 1]); // true
['a', 'a', 'b'].topOccurrence(); // 'a'
[1, 2, 3].containsAny([3, 4, 5]); // true
[1, 2, 3].itemAt(1); // 2
[1, 2, 3].itemAt(10); // null (safe access)

Null-Safe Operations

List<String> items = [];
items.addIfNotNull(null); // List remains empty
items.addIfNotNull("value"); // ["value"]

Unique Lists

[1, 2, 2, 3, 3, 3].unique(); // [1, 2, 3]

Int Extensions #

Number Formatting

1.ordinal(); // "1st"
2.ordinal(); // "2nd"
3.ordinal(); // "3rd"
21.ordinal(); // "21st"

Range Operations

5.forceBetween(1, 10); // 5
15.forceBetween(1, 10); // 10
-5.forceBetween(1, 10); // 1

Digit Counting

12345.countDigits(); // 5

Num Extensions #

Range Checks

5.isBetween(1, 10); // true
15.isBetween(1, 10); // false
5.isInRange(1, 10); // true (inclusive)

Iterable Extensions #

Random Selection

[1, 2, 3, 4, 5].randomElement(); // Random element

Set Operations

[1, 2, 3].containsAll([1, 2]); // true

Filtering & Counting

[1, 2, 3, 4, 5].countWhere((n) => n > 3); // 2

Min/Max on Comparables

[3, 1, 4, 1, 5].smallestOccurrence(); // 1
[3, 1, 4, 1, 5].biggestOccurrence(); // 5

Map Extensions #

Formatting

Map<String, dynamic> data = {'name': 'John', 'age': 30};
data.formatMap(); // Pretty-printed map

Key Removal

Map<String, dynamic> data = {'a': 1, 'b': 2, 'c': 3};
data.removeKeys(['a', 'c']); // Removes specified keys

Bool Extensions #

String Conversion

"true".toBool(); // true
"false".toBool(); // false
"TRUE".toBool(); // true (case-insensitive)

Iterable Operations

[true, true, false].allTrue; // false
[true, true, true].allTrue; // true
[false, false, false].allFalse; // true

Enum Extensions #

Safe Enum Parsing

enum Status { active, inactive, pending }

Status.values.byNameTry("active"); // Status.active
Status.values.byNameTry("invalid"); // null (safe)
Status.values.byNameTry("ACTIVE", caseSensitive: false); // Status.active

Other Utilities #

Hex Utilities

HexUtils.intToHex(255); // "FF"
HexUtils.hexToInt("FF"); // 255

Random Utilities

CommonRandom.randomInt(1, 10); // Random int between 1 and 10
CommonRandom.randomDouble(0.0, 1.0); // Random double

Gesture Utilities

SwipeProperties.fromDelta(dx: 100, dy: 10); // Detects horizontal swipe

URL Extensions

Uri url = Uri.parse("https://example.com?key=value");
url.hasQueryParameter("key"); // true

Full API Documentation #

For complete documentation of all extensions and utilities, visit:

Browse documentation by category:

Deployment Guide For Developers #

  1. Update CHANGELOG.md

  2. Format dart format . (note the trailing period ".")

  3. Test flutter test

  4. Execute dart doc

  5. Deploy flutter pub publish


🌐 📖 👥 🏢 🚨 🔒 🤝 🎯 🛡️ 📉 🆘 ⏱️ 🚑 📞 🌍 🔄 📲 💼

About Saropa #

Saropa®️ is a technology company established in 2010. We have a strong background in financial services, online security and secure web communications.

Our team has extensive experience in top-tier financial technology and we are passionate believers in personal risk management. We are engaged and excited about our vision for family security and this encourages our culture of innovation.

Saropa Contacts is a private, cloud-connected address book that links real people, companies, and emergency groups. It is primarily focused on your trusted emergency groups. Our mission is to reduce the impact of crises everywhere.

In an emergency, get real-time access to all the important people, companies, and services you need - even if you don't know them personally, or if they're not where you expect them to be.

Visit the Saropa Contacts project here: app.saropa.com

PRs, ideas and issues are always welcome! Email for any questions app.dev.utils@saropa.com or find us on Slack Saropa

💙 Saropa

3
likes
150
points
203
downloads

Publisher

verified publishersaropa.com

Weekly Downloads

Boilerplate reduction tools and human-readable extension methods by Saropa

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

GPL-3.0 (license)

Dependencies

characters, collection, flutter, jiffy

More

Packages that depend on saropa_dart_utils