kr_extensions 1.0.4 copy "kr_extensions: ^1.0.4" to clipboard
kr_extensions: ^1.0.4 copied to clipboard

This package contains a collection of extensions for Dart and Flutter.

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

Then, import the package:

import 'package:kr_extensions/kr_extensions.dart';

Or You can install packages from the command line:

flutter pub add kr_extensions

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
}

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.]
}

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
}

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
}

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
}

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
}

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
}
1
likes
120
pub points
18%
popularity

Publisher

unverified uploader

This package contains a collection of extensions for Dart and Flutter.

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

cloud_firestore, flutter, get, intl

More

Packages that depend on kr_extensions