Calculator class abstract

This abstract class represents a calculator that compute the improvement rate.

Example:

import 'package:improvement_rate/improvement_rate.dart';

void main() {
  final calculator = Calculator.instance;

  final resultShouldBeDecreased = calculator.evaluate(
    before: 100,
    after: 37,
  );

  final resultShouldBeIncreased = calculator.evaluate(
    before: 100,
    after: 37,
    policy: ShouldBe.increased,
  );

  print(resultShouldBeDecreased);
  // => ImprovementRate(value: 63.0, trend: Trend.better, policy: ShouldBe.decreased, before: 100.0, after: 37.0)

  print(resultShouldBeIncreased);
  // => ImprovementRate(value: -63.0, trend: Trend.worse, policy: ShouldBe.increased, before: 100.0, after: 37.0)

  switch (resultShouldBeDecreased.trend) {
    case Trend.better:
      return;
    case Trend.worse:
      return;
  }
}

Constructors

Calculator()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

evaluate({required double before, required double after, ShouldBe policy = ShouldBe.decreased}) ImprovementRate
Returns the improvement rate calculated from before and after based on policy.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

instance Calculator
Returns the singleton instance of Calculator.
no setter