FuelConsumption constructor

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

Class for fuel_consumption conversions, e.g. if you want to convert 1 kilometers per liter in liters per 100 km:

var fuel_consumption = Fuel_Consumption(removeTrailingZeros: false);
fuel_consumption.convert(Unit(FUEL_CONSUMPTION.kilometers_per_liter, value: 1));
print(FUEL_CONSUMPTION.liters_per_100_km);

Implementation

FuelConsumption(
    {this.significantFigures = 10,
    this.removeTrailingZeros = true,
    this.useScientificNotation = true,
    name}) {
  this.name = name ?? PROPERTY.fuelConsumption;
  size = FUEL_CONSUMPTION.values.length;
  Node conversionTree =
      Node(name: FUEL_CONSUMPTION.kilometersPerLiter, leafNodes: [
    Node(
      conversionType: CONVERSION_TYPE.reciprocalConversion,
      coefficientProduct: 100.0,
      name: FUEL_CONSUMPTION.litersPer100km,
    ),
    Node(
      coefficientProduct: 0.4251437074,
      name: FUEL_CONSUMPTION.milesPerUsGallon,
    ),
    Node(
      coefficientProduct: 0.3540061899,
      name: FUEL_CONSUMPTION.milesPerImperialGallon,
    ),
  ]);

  _customConversion = CustomConversion(
      conversionTree: conversionTree,
      mapSymbols: mapSymbols,
      significantFigures: significantFigures,
      removeTrailingZeros: removeTrailingZeros,
      useScientificNotation: useScientificNotation);
}