kr_extensions

Last updated:

0 purchases

kr_extensions Image
kr_extensions Images
Add to Cart

Description:

kr extensions

kr_extensions #
This package contains a collection of extensions for Dart and Flutter.
Get Started #
To use this package, add kr_future_builder as a dependency in your pubspec.yaml file.
dependencies:
kr_extensions: ^1.0.2
copied to clipboard
Then, import the package:
import 'package:kr_extensions/kr_extensions.dart';
copied to clipboard
Or You can install packages from the command line:
flutter pub add kr_extensions
copied to clipboard
Extensions #
StringToCurrency #
An extension on the String class to convert a string to currency format (i.e. add commas to separate the thousands).
import 'package:kr_extensions/kr_extensions.dart';

void main() {
String amount = '1000000';
print(amount.toCurrency); // Output: 1,000,000
}

copied to clipboard
StringSplit #
An extension on the String class to split a string into a list of strings, where each URL is treated as a separate string.
import 'package:kr_extensions/kr_extensions.dart';

void main() {
String text = 'Lorem ipsum https://google.com dolor sit amet, https://example.com consectetur adipiscing elit.';
List<String> texts = text.urls;
print(texts); // Output: [Lorem ipsum, https://google.com, dolor sit amet,, https://example.com, consectetur adipiscing elit.]
}

copied to clipboard
NullableIntToCurrency #
An extension on nullable numbers to convert them to currency format.
import 'package:kr_extensions/kr_extensions.dart';

void main() {
int? amount = null;
print(amount.toCurrency); // Output: 0
}

copied to clipboard
MaxMinIterable #
An extension on the Iterable<int> class to get the maximum and minimum values.
import 'package:kr_extensions/kr_extensions.dart';

void main() {
Iterable<int> numbers = [1, 2, 3, 4, 5];
print(numbers.max); // Output: 5
print(numbers.min); // Output: 1
}
copied to clipboard
StringCasingExtension #
An extension on the String class to convert the casing of the string.
import 'package:kr_extensions/kr_extensions.dart';

void main() {
String text = 'hello world';
print(text.toCapitalized()); // Output: Hello world
print(text.toTitleCase()); // Output: Hello World
}
copied to clipboard
DateTimeFormat #
An extension on the DateTime class to format the date and time.
import 'package:kr_extensions/kr_extensions.dart';

void main() {
DateTime dateTime = DateTime.now();
print(dateTime.format('MMM d, yyyy - HH:mm a')); // Output: Feb 23, 2023 - 09:12 AM
print(dateTime.fullDate); // Output: Feb 23, 2023 - 09:12 AM
print(dateTime.ago); // Output: 0 m ago
print(DateTime(2023, 2, 10).withoutTime); // Output: 2023-02-10 00:00:00.000
print(DateTime(2023, 2, 1).onlyMonth); // Output: 2023-02-01 00:00:00.000
}
copied to clipboard
toDateTime #
A function to convert a dynamic value to a DateTime object.
import 'package:kr_extensions/kr_extensions.dart';

void main() {
dynamic date = '2023/02/23 09:12:00';
DateTime? dateTime = toDateTime(date);
print(dateTime); // Output: 2023-02-23 09:12:00.000
}
copied to clipboard

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.