hiking_calories_calculator 0.1.2

hiking_calories_calculator #

A calculator for calculating burned calories during hiking that depends on the weight of the person, weight of the pack, type of the terrain and hiking speed. This calculation is based on the famous Pandolf Equation

Getting started #

In the pubspec.yaml of your flutter project, add the following dependency:

dependencies:
  ...
  hiking_calories_calculator: "^0.0.1"

Usage #

CaloriesCalculator class has static method calculateCalories that can be called to calculate calories.

  Calculation calculation = CaloriesCalculator.calculateCalories(
      weight: Weight(lbs: 120),
      bagWeight: Weight(lbs: 20),
      speed: Speed(mph: 4),
      terrain: Terrains.WET_CLAY_OR_ICE,
      inclination: 0);
  print("\nCalories per Hour:");
  print(calculation.kcalPerHour.ceil().toString());
  print("\nCalories per Mile:");
  print(calculation.kcalPerMile.ceil().toString());

Available Terrain Types: #

NoTerrain TypeTerrain FactorAccessible code
1Paved Road1.0Terrains.PAVED_ROAD
2Gravel Road1.2Terrains.GRAVEL_ROAD
3Wet Clay/Ice1.7Terrains.WET_CLAY_OR_ICE
4Sand2.0Terrains.SAND
5Swamp3.5Terrains.SWAMP

[0.1.2] - January 06, 2020

  • Add support for creating Distance instances using metres unit.
    final distance = Distance(metres: 500);

[0.1.1] - January 06, 2020

  • Code Refactor
  • minor bug fixes

[0.1.0] - January 06, 2020

  • Code Refactor
  • Add toString methods to missing classes

[0.0.1] - January 06, 2020

  • Support for calculating metabolic rate
  • Support for calculating calories burned for given weight of the user, weight of the pack, hiking speed, inclination and terrain factor.
  • Supported Weight Units: KG, Ounces, Pounds(LBS)
  • Supported Speed Units: km/h, miles/hour, m/s, knots
  • Supported Distance Units: km, miles, yards, inches, ft
  • Supported Energy Consumption Units: Watts, cal/hour, cal/min, cal/second, kcal/hour, kcal/min, kcal/second, kcal/mile
  • Supported Terrain Types: Paved Road, Gravel Road, Wet Clay/Ice, Sand, Swamp

example/main.dart

// Author: Birju Vachhani (https://github.com/birjuvachhani)
// Created Date: January 06, 2020

import 'package:hiking_calories_calculator/calculator/calculation.dart';
import 'package:hiking_calories_calculator/calculator/calories_calculator.dart';
import 'package:hiking_calories_calculator/calculator/speed.dart';
import 'package:hiking_calories_calculator/calculator/terrain_factors.dart';
import 'package:hiking_calories_calculator/calculator/weight.dart';

void main() {
  Calculation calculation = CaloriesCalculator.calculateCalories(
      weight: Weight(lbs: 120),
      bagWeight: Weight(lbs: 20),
      speed: Speed(mph: 4),
      terrain: Terrains.WET_CLAY_OR_ICE,
      inclination: 0);
  print("\nCalories per Hour:");
  print(calculation.kcalPerHour.ceil().toString());
  print("\nCalories per Mile:");
  print(calculation.kcalPerMile.ceil().toString());
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  hiking_calories_calculator: ^0.1.2

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:hiking_calories_calculator/hiking_calories_calculator.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
30
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
65
Learn more about scoring.

We analyzed this package on Feb 10, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.5

Health suggestions

Format lib/calculator/Distance.dart.

Run dartfmt to format lib/calculator/Distance.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
meta ^1.1.8 1.1.8