Energy constructor

Energy({
  1. int significantFigures = 10,
  2. bool removeTrailingZeros = true,
  3. bool useScientificNotation = true,
  4. dynamic name,
})

Class for energy conversions, e.g. if you want to convert 1 joule in kilowatt hours:

var energy = Energy(removeTrailingZeros: false);
energy.convert(Unit(ENERGY.joules, value: 1));
print(ENERGY.kilowatt_hours);

Implementation

Energy(
    {super.significantFigures,
    super.removeTrailingZeros,
    super.useScientificNotation,
    name})
    : super(
          name: name ?? PROPERTY.energy,
          mapSymbols: {
            ENERGY.joules: 'J',
            ENERGY.kilojoules: 'kJ',
            ENERGY.calories: 'cal',
            ENERGY.kilocalories: 'kcal',
            ENERGY.kilowattHours: 'kwh',
            ENERGY.electronvolts: 'eV',
            ENERGY.energyFootPound: 'ft⋅lbf',
          },
          conversionTree: ConversionNode(name: ENERGY.joules, children: [
            ConversionNode(
              coefficientProduct: 1000.0,
              name: ENERGY.kilojoules,
            ),
            ConversionNode(
              coefficientProduct: 4.1867999409,
              name: ENERGY.calories,
              children: [
                ConversionNode(
                  coefficientProduct: 1000.0,
                  name: ENERGY.kilocalories,
                ),
              ],
            ),
            ConversionNode(
              coefficientProduct: 3600000.0,
              name: ENERGY.kilowattHours,
            ),
            ConversionNode(
              coefficientProduct: 1.60217646e-19,
              name: ENERGY.electronvolts,
            ),
            ConversionNode(
              coefficientProduct: 1.3558179483314004,
              name: ENERGY.energyFootPound,
            ),
          ]));