Dart: Function Area Converter

area(area, value) {
  double acre = 0.0,
  square_mile = 0.0,
  square_foot = 0.0,
  square_inch = 0.0,
  square_km = 0.0,
  square_meter = 0.0,
  hectare = 0.0,
  square_yard = 0.0;
 
  if (area == 'acre') {
    hectare = value * 0.404686;
    square_foot = value * 43560;
    square_inch = value * 6.273e6;
    square_km = value * 0.00404686;
    square_meter = value * 4046.86;
    square_mile = value * 0.0015625;
    square_yard = value * 4840;
  } else if (area == 'square_mile') {
    acre = value * 640;
    square_foot = value * 2.788e7;
    square_inch = value * 4.014e9;
    square_km = value * 2.58999;
    square_meter = value * 2.59e6;
    hectare = value * 258.999;
    square_yard = value * 3.098e6;
  } else if (area == 'square_foot') {
    acre = value * 2.2957e-5;
    hectare = value * 9.2903e-6;
    square_inch = value * 144;
    square_km = value * 9.2903e-8;
    square_meter = value * 0.092903;
    square_mile = value * 3.587e-8;
    square_yard = value * 0.111111;
  } else if (area == 'square_inch') {
    acre = value * 1.5942e-7;
    square_foot = value * 0.00694444;
    hectare = value * 6.4516e-8;
    square_km = value * 6.4516e-10;
    square_meter = value * 0.00064516;
    square_mile = value * 2.491e-10;
    square_yard = value * 0.000771605;
  } else if (area == 'square_km') {
    acre = value * 247.105;
    square_foot = value * 1.076e7;
    square_inch = value * 1.55e9;
    hectare = value * 100;
    square_meter = value * 1e6;
    square_mile = value * 0.386102;
    square_yard = value * 1.196e6;
  } else if (area == 'square_meter') {
    acre = value * 0.000247105;
    square_foot = value * 10.7639;
    square_inch = value * 1550;
    square_km = value * 1e-6;
    hectare = value * 1e-4;
    square_mile = value * 3.861e-7;
    square_yard = value * 1.19599;
  } else if (area == 'hectare') {
    acre = value * 2.47105;
    square_foot = value * 107639;
    square_inch = value * 1.55e7;
    square_km = value * 0.01;
    square_meter = value * 10000;
    square_mile = value * 0.00386102;
    square_yard = value * 11959.9;
  } else if (area == 'square_yard') {
    acre = value * 0.000206612;
    square_foot = value * 9;
    square_inch = value * 1296;
    square_km = value * 8.3613e-7;
    square_meter = value * 0.836127;
    square_mile = value * 3.2283e-7;
    hectare = value * 8.3613e-5;
  }
  return "acre:$acre \nsquare_foot:$square_foot\nsquare_inch:$square_inch\nsquare_km:$square_km\nsquare_meter:$square_meter\nhectare:$hectare\nsquare_yard:$square_yard";
}

void main() {
  print(area('square_foot', 2));
}

No comments:

Why Carousels Are a Poor Way to View Product Images

Introducing the scrolling image stream ͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏  ...

Contact Form

Name

Email *

Message *