Area constructor

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

Class for area conversions, e.g. if you want to convert 1 square meters in acres:

var area = Area(removeTrailingZeros: false);
area.convert(Unit(AREA.square_meters, value: 1));
print(AREA.acres);

Implementation

Area(
    {this.significantFigures = 10,
    this.removeTrailingZeros = true,
    this.useScientificNotation = true,
    name}) {
  this.name = name ?? PROPERTY.area;
  size = AREA.values.length;
  Node conversionTree = Node(name: AREA.squareMeters, leafNodes: [
    Node(coefficientProduct: 1e-4, name: AREA.squareCentimeters, leafNodes: [
      Node(coefficientProduct: 6.4516, name: AREA.squareInches, leafNodes: [
        Node(
          coefficientProduct: 144.0,
          name: AREA.squareFeet,
        ),
        Node(
          coefficientProduct: 12.000024 * 12.000024,
          name: AREA.squareFeetUs,
        ),
      ]),
    ]),
    Node(
      coefficientProduct: 1e-6,
      name: AREA.squareMillimeters,
    ),
    Node(
      coefficientProduct: 10000.0,
      name: AREA.hectares,
    ),
    Node(
      coefficientProduct: 1000000.0,
      name: AREA.squareKilometers,
    ),
    Node(coefficientProduct: 0.83612736, name: AREA.squareYard, leafNodes: [
      Node(
        coefficientProduct: 3097600.0,
        name: AREA.squareMiles,
      ),
      Node(
        coefficientProduct: 4840.0,
        name: AREA.acres,
      ),
    ]),
    Node(
      coefficientProduct: 100.0,
      name: AREA.are,
    ),
  ]);

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