Introducing XUtils Pack: Simplify Your Flutter Development with Powerful Extensions!

 


    Flutter developers often encounter repetitive tasks when handling common data types like String, int, double, and DateTime. These tasks, though essential, can clutter your code and make it harder to maintain. That’s where XUtils Pack comes in—a powerful Dart/Flutter package designed to streamline your workflow and make your code cleaner, more readable, and efficient.

What is XUtils Pack?

XUtils Pack is a Dart/Flutter library that provides a collection of extensions for common data types. Whether you're working with numbers, strings, or dates, XUtils Pack offers convenient methods that simplify your coding tasks.

Key features include:

  • Extensions for DateTime, double, intString, list and other
  • Utility methods for common operations, like formatting, parsing, or extracting numeric values
  • Cleaner and more readable code, reducing boilerplate in your projects

This package is compatible across platforms, including Android, iOS, Web, Windows, macOS, and Linux, making it versatile for cross-platform Flutter apps.

Core Features and Examples

1. Currency Formatting

XUtils Pack makes it easy to format numbers as currency:

double price = 15000.5; print(price.toCurrency()); // e.g., "15,000.50" String priceStr = '20000'; print(priceStr.toCurrency()); // e.g., "20,000.00"

This feature helps you avoid repetitive manual formatting and ensures consistency across your app.

2. Numeric Operations

Extract numbers from strings or convert them to int or double effortlessly:

print("a1b2c3".numericOnly()); // Output: "123" print("12.5a".toDouble()); // Output: 12.5 print("123a".toInt()); // Output: 123

3. Sorting Utilities

XUtils Pack offers a convenient sortIt() extension that simplifies sorting:

final nums = [3, 1, 5, 2]; final sorted = nums.sortIt(); print(sorted); // Output: [1, 2, 3, 5]

You can even sort custom objects using a selector function:

final people = [ {"name": "Charlie", "age": 30}, {"name": "Alice", "age": 20}, {"name": "Bob", "age": 25}, ]; final sortedPeople = people.sortIt((p) => p["age"] as int); print(sortedPeople.map((p) => p["age"])); // Output: [20, 25, 30]

This avoids messy comparisons and keeps your code concise.

Why Choose XUtils Pack?

  • Time-saving: Reduces boilerplate for common operations
  • Readable code: Extensions make your code more intuitive
  • Cross-platform support: Works on mobile, desktop, and web
  • Open-source: MIT licensed, encouraging community contributions

Whether you’re building a small utility app or a complex enterprise-level Flutter project, XUtils Pack can help streamline your workflow and improve maintainability.

Getting Started

To add XUtils Pack to your Flutter project, include it in your pubspec.yaml:

dependencies: xutils_pack: ^lates

Then run:

flutter pub get

You’re ready to start using the handy extensions provided by XUtils Pack.

XUtils Pack is a lightweight but powerful Dart/Flutter package that simplifies everyday programming tasks. From formatting currencies to sorting data and parsing numbers, it enhances code readability and productivity. If you want to write cleaner, more maintainable Flutter code, XUtils Pack is a must-have in your toolkit.

Explore XUtils Pack on pub.dev and start simplifying your Flutter development today!

Post a Comment

0 Comments