heartinz_essentials 3.1.0
heartinz_essentials: ^3.1.0 copied to clipboard
Essentials provides a set of ready-to-use tools for calculations, date and time manipulations, currency conversions, and GST (tax) computations, making it an all-in-one solution for developers
example/example.dart
import 'package:heartinz_essentials/heartinz_essentials.dart';
void main() {
// Create an instance of Essentials
final essentials = Essentials();
// Example 1: Grand Total Calculation
// GrandTotalModel grandTotal = essentials.calc.calculateGrandTotal(
// totalMrp: essentials.currency.toSubunit(0.5, "INR"),
// totalSalePrice: essentials.currency.toSubunit(0.245, "INR"),
// totalBasePrice: essentials.currency.toSubunit(1, "INR"),
// totalTaxAmount: 18,
// );
// print('/// GRAND TOTAL /// \n ${grandTotal.toMap()}');
// Example 2: Convert to Currency
// double currencyValue = essentials.currency.toCurrency(1500, 'USD');
// print('/// CONVERT TO CURRENCY /// \n $currencyValue');
// Example 3: Convert to Subunits
// int subunitValue = essentials.currency.toSubunit(1500.75, 'USD');
// print('/// CONVERT TO SUBUNITS /// \n $subunitValue');
// Example 4: GST Calculation
GSTResult gstDetails = essentials.calc.gstCalculate(
mrp: essentials.currency.toSubunit(200, "INR"),
salePrice: essentials.currency.toSubunit(150, "INR"),
basePrice: essentials.currency.toSubunit(0, "INR"),
taxPercent: 18,
quantity: 99999999.001,
lock: "SALEPRICE",
);
print('/// GST DETAILS /// \n ${gstDetails.toJson()}');
// Example 5: Date and Time Operations - ISO to Display Format
// String isoString = "2024-12-16T15:30:00Z";
// var displayTime = essentials.date.displayIso(isoString);
// print('/// DISPLAY IN ISO /// \n $displayTime');
// Example 6: Split ISO String
// var isoSplit = essentials.date.splitIso(isoString);
// print('/// SPLIT ISO /// \n $isoSplit');
// Example 7: Convert to Target Time Zone
// String targetTimeZone = "Asia/Kolkata";
// var timeInTargetZone = essentials.date.toTimeZone(isoString, targetTimeZone);
// print(
// '/// CONVERT TO TARGET TIME ZONE /// \n $targetTimeZone: $timeInTargetZone');
// Example 8: Current Time by Time Zone
// var currentTime = essentials.date.getCurrentTimeByTimeZone("Asia/Kolkata");
// print('/// CURRENT TIME BY TIME ZONE /// \n $currentTime');
// Example 9: Day Boundaries in UTC
// String isoDateStr = "2024-12-16T15:30:00Z";
// var dayBoundaries = essentials.date.dayBoundariesInUTC(isoDateStr);
// print('/// DAY BOUNDRIES /// \n $dayBoundaries');
// Example 10: Time Difference Between Two Dates
// var timeDifference = essentials.date.timeDifference(
// "2024-12-16T15:30:00Z", "2024-12-17T16:30:00Z");
// print('/// TIME DIFFERENCE /// \n $timeDifference');
// Example 11: Modify ISO Time by Duration
// String modifiedIsoTime =
// essentials.date.modifyIso(isoString, Duration(hours: 2));
// print('/// MODIFY ISO TIME BY DURATION /// \n $modifiedIsoTime');
// Example 12: Convert Date to ISO Format
// String dateStr = "2024-12-16";
// String type = "MM-dd-yyyy";
// String timeZone = "Asia/Kolkata";
// String isoFormat = essentials.date.toIso(
// dateStr: dateStr, type: type, timeZone: timeZone);
// print('/// TO ISO FORMAT /// \n $isoFormat');
// Example 13: Convert to UTC
// var utcTime = essentials.date.toUtc(isoString);
// print('/// TO UTC /// \n $utcTime');
}