dart_extensions_pro
A Dart package that provides handy extensions and helper functions, designed to simplify and speed up development, making coding more efficient and streamlined.
Types of Extensions
📊 Comparison
📅 Date Handling
✍️ String Utilities
📋 List Enhancements
🧭 Navigation
👆 Tap Gestures
🔁 Iterable Enhancements
🎨 Color Conversion
🔢 Number Utilities
🛠️ Utility Functions
Analytics
Visit EXTENSIONS.md for a complete list of all the available extensions.
Extensions: 271
Helper Classes: 7
Helper Functions & Getters: 21
Typedefs: 7
Mixins: 2
Getting started
Add dependency to your pubspec.yaml file & run Pub get
dependencies:
dart_extensions_pro: ^0.0.4
And import package into your class file
import 'package:dart_extensions_pro/dart_extensions_pro.dart';
Here’s a quick preview of dart_extensions_pro
String extension:
'hello'.iscapitalize();
'Copy this text'.copyTo();
'test@example.com'.isValidEmail();
'flutter'.reverse();
'madam'.isPalindrome();
'flutter example'.toCamelCase();
'{"name": "Flutter"}'.decodeJson();
Comparison extension:
5.gt(3);
3.lt(5);
5.eq(5);
3.lte(3);
5.gte(3);
5.ne(3);
Date extension
DateTime.now().isSameDate(DateTime(2023, 9, 14));
DateTime.now().isToday();
DateTime.now().isTomorrow();
DateTime.now().wasYesterday();
DateTime.now().addDays(5);
DateTime.now().addMonths(3);
DateTime.now().addYears(2);
DateTime.now().subtractDays(7);
DateTime.now().subtractMonths(1);
DateTime.now().subtractYears(1);
List extension
final list = [1, 2, 3] << 4;
list.replaceFirstWhere(10, (item) => item == 2);
list.replaceLastWhere(20, (item) => item > 1);
Navigation extension
context.to(MyPage());
context.toNamed('/home');
context.back();
context.backUntil((route) => route.isFirst);
context.toWithReplace(AnotherPage());
context.replaceWithNamed('/dashboard');
context.toAndRemoveAll(HomePage(), (route) => false);
context.toNamedAndRemoveAll('/login', (route) => false);
Gesture extension
widget.onInkTap(() => 'Tapped!'.logMsg());
widget.onTap(() => 'Tapped!'.logMsg());
widget.onDoubleTap(() => 'Double Tapped!'.logMsg());
widget.onTapCancel(() => 'Tap Cancelled!'.logMsg());
widget.onLongPress(() => 'Long Pressed!'.logMsg());
widget.onTapDown((details) => 'Tap Down!'.logMsg());
widget.onScale(
onScaleStart: (details) => 'Scale Started!'.logMsg(),
onScaleUpdate: (details) => 'Scaling!'.logMsg(),
onScaleEnd: (details) => 'Scale Ended!'.logMsg(),
);
Iterable extension
iterable.lastElementIndex;
iterable.hasSingleElement;
iterable.addAllMatchingTo(targetList, (e) => e.isEven);
iterable.whereFilter((e) => e.isEven);
iterable.whereFilterIndexed((index, e) => index % 2 == 0);
iterable.mapTransform((e) => e.toString());
iterable.skipElements(2);
iterable.takeLastElements(2);
iterable.skipWhileElements((e) => e < 5);
iterable.skipLastElements(2);
Color conversion
String.toColor();
HexColor.getColorFromHex(hexColor);
HexColor(hexColor);
Number conversion
num.negative;
num.isBetween(value1, value2, {inclusive = false});
num.roundToDecimals(decimalPlaces);
double.asRadians;
double.asDegrees;
T.maxim(upperBound, {exclusive = false});
T.minm(lowerBound, {exclusive = false});
T.clampAtMin(lowerBound);
T.clampAtMax(upperBound);
num.orZero;
num.orOne;
num.or(value);
Utility conversion
double.isWhole;
double.roundToPrecision(nthPosition);
bool.isCloseTo(other, {precision = 1.0e-8});
double.randomDouble({max});
int Duration.inYears;
bool Duration.isInYears;
int Duration.absoluteSeconds;
void Map<K, V>.operator <<(MapEntry<K, V> entry);
String Map<K, V>.toJson();
Code Contributors
Made with ❤️ by the DevCodeSpace