dev_ease 0.0.1 copy "dev_ease: ^0.0.1" to clipboard
dev_ease: ^0.0.1 copied to clipboard

A Flutter package that simplifies development tasks with utility functions for date manipulation, string operations, and more, aiming to enhance productivity for Flutter developers.

0.0.1 Initial Release #

This library was created to make development easier and promote code reuse by providing a set of string manipulation utilities. It aims to simplify common string operations, allowing developers to focus more on building features rather than repetitive tasks.

If you have any suggestions for additional methods or features to include, please feel free to reach out at muhmmdshabeer@gmail.com.

Description #

This release introduces a collection of string manipulation utilities in Dart, encapsulated in extensions that provide various useful methods. These extensions aim to enhance developers' productivity by simplifying common string operations, including HTML entity conversion, formatting, and number parsing.

Features #

1. HTML Entity Conversion

  • Method: String convertHtmlEntities()
  • Description: Converts commonly used HTML special characters into their corresponding plain text representations, allowing developers to handle user-generated content or data fetched from web sources effectively.
  • Supported Entities:
    • &&
    • ""
    • &lt;<
    • &gt;>
    • &nbsp;
    • &copy;©
    • Other common entities such as &dollar;, &#39;, etc.

Usage Example:

String htmlString = "Tom &amp; Jerry &copy; 2024";
String plainText = htmlString.convertHtmlEntities(); 
// Output: "Tom & Jerry © 2024"

2. Remove Decimal Zero

  • Method: String removeDecimalZero()
  • Description: Removes the decimal part from a string representing a number if the value is an integer. If the string cannot be parsed as a number, the original string is returned.

Usage Example:

String numberString = "45.0";
String formattedNumber = numberString.removeDecimalZero(); 
// Output: "45"

3. Convert to Integer

  • Method: int? toInt()
  • Description: Converts the string to an integer. If the string cannot be parsed as a valid integer, it returns 0.

Usage Example:

String numberString = "42";
int? integerValue = numberString.toInt(); 
// Output: 42

4. Convert to Double

  • Method: double? toDouble()
  • Description: Converts the string to a double. Returns 0.0 if parsing fails.

Usage Example:

String numberString = "3.14";
double? doubleValue = numberString.toDouble(); 
// Output: 3.14

5. Capitalize First Letter

  • Method: String toCapitalize()
  • Description: Capitalizes the first letter of the string. If the string is null or empty, it returns an empty string.

Usage Example:

String text = "hello";
String capitalizedText = text.toCapitalize(); 
// Output: "Hello"

6. Capitalize Each Word in Sentence

  • Method: String toCapitalizeSentence()
  • Description: Capitalizes the first letter of each word in a sentence. Returns an empty string if the input is null.

Usage Example:

String sentence = "hello world";
String capitalizedSentence = sentence.toCapitalizeSentence(); 
// Output: "Hello World"

7. Convert to Snake Case

  • Method: String toSnakeCase()
  • Description: Converts spaces in the string to underscores and transforms all characters to lowercase. Returns an empty string if the input is null.

Usage Example:

String phrase = "Hello World";
String snakeCase = phrase.toSnakeCase(); 
// Output: "hello_world"

8. Convert to Kebab Case

  • Method: String toKebabCase()
  • Description: Converts spaces in the string to hyphens and transforms all characters to lowercase. Returns an empty string if the input is null.

Usage Example:

String phrase = "Hello World";
String kebabCase = phrase.toKebabCase(); 
// Output: "hello-world"

9. Contains Ignoring Case

  • Method: bool containsIgnoreCase(String str)
  • Description: Checks if the string contains the specified substring, ignoring case sensitivity. Returns false if the input string is null.

Usage Example:

String text = "Hello World";
bool containsHello = text.containsIgnoreCase("hello"); 
// Output: true

Additional Extension: Zero Appender #

10. Append Zero for Single Digits

  • Extension: ZeroAppender on int
  • Method: String appendZero()
  • Description: Prepends a zero to single-digit integers (1-9) for consistent formatting.

Usage Example:

int singleDigit = 5;
String formattedDigit = singleDigit.appendZero(); 
// Output: "05"

Additional Extension: Date Formatting #

11. Custom Date Formatting

  • Extension: DateFormatExtension on Object?
  • Method: String formatToCustomDate({required String inputFormat, required String outputFormat})
  • Description: Converts a date string or DateTime object from a specified input format to a specified output format. Returns 'Invalid input' if the input is null.

Usage Example:

String dateString = "2024-10-08";
String formattedDate = dateString.formatToCustomDate(
  inputFormat: "yyyy-MM-dd",
  outputFormat: "dd/MM/yyyy"
); 
// Output: "08/10/2024"

12. Convert UTC to Local Time

  • Method: String formatUTCToLocal({required String inputFormat, required String outputFormat})
  • Description: Converts a UTC date string or DateTime object to local date and time in a specified output format.

Usage Example:

String utcDateString = "2024-10-08T12:00:00Z";
String localDate = utcDateString.formatUTCToLocal(
  inputFormat: "yyyy-MM-ddTHH:mm:ssZ",
  outputFormat: "dd/MM/yyyy HH:mm"
); 
// Output: "08/10/2024 18:30" (depending on local time)

8
likes
140
points
42
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A Flutter package that simplifies development tasks with utility functions for date manipulation, string operations, and more, aiming to enhance productivity for Flutter developers.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter, intl

More

Packages that depend on dev_ease