octopus_extensions 2.2.8
octopus_extensions: ^2.2.8 copied to clipboard
Pack of extensions and helters for day to day code boost
extensions #
extensions is a lightweight Dart package that extends core types like Duration
, Iterable
, String
, Number
, and DateTime
with additional convenient methods.
Features #
- Extended functionality for
Duration
,Iterable
,String
,Number
, andDateTime
. - Utility methods to simplify and clean your Dart code.
- No external dependencies.
Getting started #
Add this to your pubspec.yaml
:
dependencies:
extensions: ^latest
Then run:
flutter pub get
or
dart pub get
Import it in your Dart code:
import 'package:octopusllc/extensions.dart';
Usage Examples #
Duration Extensions #
Duration duration = 5.minutes;
Duration combined = 2.hours + 30.minutes;
Iterable Extensions #
List<int> numbers = [1, 2, 3, 4];
int sum = numbers.sum; // Returns 10
double average = numbers.average; // Returns 2.5
String Extensions #
String example = " Hello World ";
String trimmed = example.trimmed; // "Hello World"
bool isNumeric = "1234".isNumeric; // true
bool isEmail = "test@example.com".isValidEmail; // true
Number Extensions #
int value = 3;
bool isEven = value.isEven; // false
DateTime Extensions #
DateTime now = DateTime.now();
bool today = now.isToday;
bool tomorrow = now.isTomorrow;
bool yesterday = now.isYesterday;
DateTime startOfMonth = now.startOfMonth();
DateTime endOfMonth = now.getLastDayOfMonth;
DateTime corrected = now.intervalCorrection(15);
License #
This project is licensed under the MIT License.