这是indexloc提供的服务,不要输入任何密码

libcalculator 1.2.0 copy "libcalculator: ^1.2.0" to clipboard
libcalculator: ^1.2.0 copied to clipboard

A mathematical expression evaluator for Dart that handles arithmetic operations, parentheses, decimal numbers, and proper operator precedence with precise calculations.

LibCalculator #

A mathematical expression evaluator for Dart that handles arithmetic operations with proper precedence rules.

Features #

  • Evaluates mathematical expressions with support for:
    • Basic arithmetic operations (+, -, *, /)
    • Parentheses for expression grouping
    • Decimal numbers
    • Proper operator precedence
  • Clean error handling for invalid expressions
  • Automatic result formatting (integers or decimals)
  • Precise calculations with rounding to 10 decimal places

Getting started #

Add this package to your project's dependencies:

dependencies:
  libcalculator: ^1.2.0

Then run:

dart pub get

Usage #

Simple usage example:

import 'package:libcalculator/libcalculator.dart';

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

  // Basic arithmetic
  print(calculator.calculate('2 + 3'));  // Output: 5

  // Expression with parentheses
  print(calculator.calculate('2 * (3 + 4)'));  // Output: 14

  // Decimal numbers
  print(calculator.calculate('10 / 3'));  // Output: 3.3333333333

  // Complex expressions
  print(calculator.calculate('(2.5 + 3.5) * (4 - 1) / 2'));  // Output: 9
}
0
likes
160
points
37
downloads

Publisher

unverified uploader

Weekly Downloads

A mathematical expression evaluator for Dart that handles arithmetic operations, parentheses, decimal numbers, and proper operator precedence with precise calculations.

Repository (GitHub)

Topics

#calculator #mathematics

Documentation

API reference

License

BSD-3-Clause (license)

More

Packages that depend on libcalculator