heartinz_essentials 2.0.3
heartinz_essentials: ^2.0.3 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.calculateGrandTotal(
// totalMrp: essentials.toSubunit(0.5, "INR"),
// totalSalePrice: essentials.toSubunit(0.245, "INR"),
// totalBasePrice: essentials.toSubunit(1, "INR"),
// totalTaxAmount: 18,
// );
// print('/// GRAND TOTAL /// \n ${grandTotal.toMap()}');
// // // Example 2: Convert to Currency
// double currencyValue = essentials.convertToCurrency(1500, 'USD');
// print('/// CONVERT TO CURRENCY /// \n $currencyValue');
// // // Example 3: Convert to Subunits
// int subunitValue = essentials.convertToSubunits(1500.75, 'USD');
// print('/// CONVERT TO SUBUNITS /// \n $subunitValue');
// Example 4: GST Calculation
GSTResult gstDetails = essentials.gstCalculate(
mrp: essentials.toSubunit(3.534342, "INR"),
salePrice: essentials.toSubunit(4234234, "INR"),
basePrice: essentials.toSubunit(534534, "INR"),
taxPercent: 43242,
quantity: 43242243,
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.displayIso(isoString);
// print('/// DISPLAY IN ISO /// \n $displayTime');
// // // Example 6: Convert ISO to All Formats
// var isoToAll = essentials.isoToAll(isoString);
// print('/// CONVERT TO ISO /// \n $isoToAll');
// // // Example 7: Convert to Target Time Zone
// String targetTimeZone = "Asia/Kolkata";
// var timeInTargetZone = essentials.toTimeZone(isoString, targetTimeZone);
// print(
// '/// CONVERT TO TARGET TIME ZONE /// \n $targetTimeZone: $timeInTargetZone');
// // // Example 8: Current Time by Time Zone
// var currentTime = essentials.currentTimeByTimeZone("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.dayBoundariesInUTC(isoDateStr);
// print('/// DAY BOUNDRIES /// \n $dayBoundaries');
// // // Example 10: Time Difference Between Two Dates
// var timeDifference =
// essentials.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.modifyIso(isoString, Duration(hours: 2));
// print('/// MODIFY ISO TIME BY DURATION /// \n $modifiedIsoTime');
// // // Example 12: Split ISO String
// var splitIso = essentials.splitIso(isoString);
// print('/// SPLIT ISO /// \n $splitIso');
// // // Example 13: Convert Date to ISO Format
// String dateStr = "2024-12-16 ";
// String type = "MM-dd-yyyy";
// String timeZone = "Asia/Kolkata";
// String isoFormat =
// essentials.toIso(dateStr: dateStr, type: type, timeZone: timeZone);
// print('/// TO ISO FORMAT /// \n $isoFormat');
}