mate 0.0.5 copy "mate: ^0.0.5" to clipboard
mate: ^0.0.5 copied to clipboard

A simple and lightweight math library, that can parse and calculate string expressions.

example/main.dart

import 'package:mate/mate.dart';

/*
  This file is just a simple implementation example of mate.

  See official documentation/explanation of working style of mate. - [https://github.com/theiskaa/mate#readme]  
  And here is UI/Flutter implementation of mate - [https://github.com/theiskaa/mate/blob/main/example/app.dart]

*/

void main() {
  // Create new mate instance.
  final Mate mate = Mate();

  const expressions = [
    '2+2', // 4
    '-2 + 5 + 10 * 2', // 23
    '10 % 2 + 0.8 + 19 / 2 - 0.5', // 10
    '((20 / 4) * (20 / 5)) / 2 + (2.5 * 2)', // 15
    "*2abc-10/%" // null (invalid),
  ];

  for (var expression in expressions) {
    // use [calculate] function, to parse, and calculate expression.
    final result = mate.calculate(expression);
    print(result);
  }
}
3
likes
130
pub points
53%
popularity

Publisher

verified publishertheiskaa.com

A simple and lightweight math library, that can parse and calculate string expressions.

Repository (GitHub)
View/report issues

Documentation

Documentation
API reference

License

MIT (license)

More

Packages that depend on mate